Difference between revisions of "Introduction to LabVIEW"

From EG1004 Lab Manual
Jump to: navigation, search
Line 3: Line 3:


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. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. The logic of graphical programming will be shown during the course of this lab.
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. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. The logic of graphical programming will be shown during the course of this lab.
a
 
= Overview =
= Overview =
''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>''
''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>''


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


The '''''front panel''''' is built using '''''controls''''' and '''''indicators'''''. '''''Controls''''' are '''inputs''' &mdash; they allow a user to supply information to the VI. '''''Indicators''''' are '''outputs''' &mdash; they display the results based on the inputs given to the VI. Controls consist of switches, knobs, dials, and buttons, whereas indicators consist of meters, gauges, LEDs, and displays. These are located on the '''''controls palette''''' and can be placed on the front panel.
The '''''front panel''''' is built using '''''controls''''' and '''''indicators'''''. '''''Controls''''' are '''inputs''' &mdash; they allow a user to supply information to the VI. '''''Indicators''''' are '''outputs''' &mdash; they display the results based on the inputs given to the VI. Controls consist of switches, knobs, dials, and buttons, whereas indicators consist of meters, gauges, LEDs, and displays. These are located on the '''''controls palette''''' and can be placed on the front panel.
Line 60: Line 60:
* Lab PC
* Lab PC
* LabVIEW software
* LabVIEW software
* Data acquisition and control (DAC) board
* NI-ELVIS II+ prototyping board
* Breadboard
* Several LEDs


= Procedure =
= Procedure =
Line 70: Line 68:
# On the left window, pull down the '''''View''''' menu again, select '''''Controls Palette'''''. At this point, the screen should look like Figure 1. Note the '''''controls palette''''' and the '''''tools palette''''', and their icons.
# On the left window, pull down the '''''View''''' menu again, select '''''Controls Palette'''''. At this point, the screen should look like Figure 1. Note the '''''controls palette''''' and the '''''tools palette''''', and their icons.


[[Image:lab_labview_1.gif|frame|center|Figure 1: LabVIEW workspace.]]
[[Image:lab_labview_1.png|thumb|720px|center|Figure 1: LabVIEW workspace.]]


'''''Remember:''' Notes are required. Experimental details are easily forgotten unless written down. EG Standard Note Paper can be downloaded and printed from the EG website [http://eg.poly.edu/downloads/Note_paper.zip the EG Website]. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, the TA will scan the lab notes and upload them to the [http://eg.poly.edu/documents.php Lab Documents] section of the EG Website. The lab notes must be attached at the end of the lab report (use the "Insert Object" command in MS Word after your Conclusion). Keeping careful notes is an essential component of all scientific practice.''
'''''Remember:''' Notes are required. Experimental details are easily forgotten unless written down. EG Standard Note Paper can be downloaded and printed from the EG website [http://eg.poly.edu/downloads/Note_paper.zip the EG Website]. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, the TA will scan the lab notes and upload them to the [http://eg.poly.edu/documents.php Lab Documents] section of the EG Website. The lab notes must be attached at the end of the lab report (use the "Insert Object" command in MS Word after your Conclusion). Keeping careful notes is an essential component of all scientific practice.''
Line 85: Line 83:
# The '''''front panel''''' must contain:
# The '''''front panel''''' must contain:
## One slide to control the arithmetic operation to be performed. The instructions are:
## One slide to control the arithmetic operation to be performed. The instructions are:
### Select the '''Numeric''' icon [[Image:lab_labview_2.gif]] under '''Modern''' on the '''''controls palette''''' (see Figure 2). This will bring up the window shown in Figure 3.
### Select the '''Numeric''' icon [[Image:lab_labview_2.png]] under '''Modern''' on the '''''controls palette''''' (see Figure 2). This will bring up the window shown in Figure 3.
###: [[Image:lab_labview_3.gif|frame|center|Figure 2: Controls palette.]]
###: [[Image:lab_labview_3.png|frame|center|Figure 2: Controls palette.]]
###: [[Image:lab_labview_5.gif|frame|center|Figure 3: Modern numeric controls.]]
###: [[Image:lab_labview_5.png|frame|center|Figure 3: Modern numeric controls.]]
### Select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide on the front panel at any location.
### Select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide on the front panel at any location.
###: Note: The slide may be moved by clicking on it and holding down the left mouse button to drag the control to a preferred location. When correctly located, let go of the left mouse button. This will work for all items in both the front and back panels.
###: Note: The slide may be moved by clicking on it and holding down the left mouse button to drag the control to a preferred location. When correctly located, let go of the left mouse button. This will work for all items in both the front and back panels.
###: Note: When items are placed on the front panel (left window), symbols corresponding to each item will appear on the back panel (right window). When the front panel is complete, the items on the back panel will be wired to make the calculator work.
###: Note: When items are placed on the front panel (left window), symbols corresponding to each item will appear on the back panel (right window). When the front panel is complete, the items on the back panel will be wired to make the calculator work.
### Click on the number 10 and change it to 2. Now the slide control will look like Figure 4.
### Click on the number 10 and change it to 2. Now the slide control will look like Figure 4.
###: [[Image:lab_labview_6.gif|frame|center|Figure 4: Slide control with range changed from 10 to 2.]]
###: [[Image:lab_labview_6.png|frame|center|Figure 4: Slide control with range changed from 10 to 2.]]
### Right click on the slide to bring up a pull down menu. Select '''Representation''', and choose the '''I8''' icon. Figure 5 shows what the pull down menus look like and the I8 icon. This completes the slide control on the front panel.
### Right click on the slide to bring up a pull down menu. Select '''Representation''', and choose the '''I8''' icon. Figure 5 shows what the pull down menus look like and the I8 icon. This completes the slide control on the front panel.
###: [[Image:lab_labview_7.gif|frame|center|Figure 5: Data type representation pull down menu.]]
###: [[Image:lab_labview_7.png|frame|center|Figure 5: Data type representation pull down menu.]]
## Three Boolean indicators to specify the operation selected. The instructions are:
## Three Boolean indicators to specify the operation selected. The instructions are:
### On the '''''controls palette''''', select the '''Boolean''' icon [[Image:lab_labview_8.gif]] under '''Modern'''. This will bring up the window shown in Figure 6.
### On the '''''controls palette''''', select the '''Boolean''' icon [[Image:lab_labview_8.png]] under '''Modern'''. This will bring up the window shown in Figure 6.
###: [[Image:lab_labview_9.gif|frame|center|Figure 6: Modern boolean controls.]]
###: [[Image:lab_labview_9.png|frame|center|Figure 6: Modern boolean controls.]]
### Select the '''Round LED''' icon from the icons shown. Click on the left window to place the LED on the front panel at a specific location. 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 created so there are three lights in a row under the slide.
### Select the '''Round LED''' icon from the icons shown. Click on the left window to place the LED on the front panel at a specific location. 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 created so there are three lights in a row under the slide.
### Rename the three LEDs to correspond to the functions the calculator will be performing: add, subtract, and multiply. To rename each LED, click on the '''Edit Text''' icon [[Image:lab_labview_10.gif]] on the '''''tools palette'''''. Then click on the labels 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.
### Rename the three LEDs to correspond to the functions the calculator will be performing: add, subtract, and multiply. To rename each LED, click on the '''Edit Text''' icon [[Image:lab_labview_10.png]] on the '''''tools palette'''''. Then click on the labels 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.
## Two numeric controls will allow the user to input data from the keyboard. The instructions are:
## Two numeric controls will allow the user to input data from the keyboard. The instructions are:
### On the '''''controls palette''''', click on the '''Numeric''' icon under '''Modern'''. This will bring up the window shown in Figure 3 again.
### On the '''''controls palette''''', click on the '''Numeric''' icon under '''Modern'''. This will bring up the window shown in Figure 3 again.
Line 107: Line 105:
###: '''Note''': This numeric indicator, used for output, is a different type of object from the two numeric controls (which are for input) that was constructed earlier in Item c.
###: '''Note''': This numeric indicator, used for output, is a different type of object from the two numeric controls (which are for input) that was constructed earlier in Item c.
### The finished front panel should look like Figure 7:
### The finished front panel should look like Figure 7:
###: [[Image:lab_labview_13.gif|frame|center|Figure 7: Finished front panel.]]
###: [[Image:lab_labview_13.png|frame|center|Figure 7: Finished front panel.]]
#: As stated earlier, on the back panel there are icons corresponding to everything that was placed on the front panel. They will be arranged, additional objects will be added, and they will be wired to make the calculator work.
#: As stated earlier, on the back panel there are icons corresponding to everything that was placed on the front panel. They will be arranged, additional objects will be added, and they will be wired to make the calculator work.
# The '''''back panel''''' must contain:
# The '''''back panel''''' must contain:
## At least one case statement to control the arithmetic operations. This case statement will be the heart of the calculator. The instructions are:
## At least one case statement to control the arithmetic operations. This case statement will be the heart of the calculator. The instructions are:
### 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 will be filled in at the next few steps. The back panel should look like Figure 8.
### 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 will be filled in at the next few steps. The back panel should look like Figure 8.
###: [[Image:lab_labview_14.gif|frame|center|Figure 8: Rearranged back panel.]]
###: [[Image:lab_labview_14.png|frame|center|Figure 8: Rearranged back panel.]]
### In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose '''''Functions Palette'''''. This will bring up the '''''functions palette''''', shown in Figure 9.
### In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose '''''Functions Palette'''''. This will bring up the '''''functions palette''''', shown in Figure 9.
###: [[Image:lab_labview_16.gif|frame|center|Figure 9: '''''Functions palette'''''.]]
###: [[Image:lab_labview_16.png|frame|center|Figure 9: '''''Functions palette'''''.]]
### Click on the '''Structures''' icon [[Image:lab_labview_17.gif]] under '''Programming'''. This will bring up the window shown in Figure 10.
### Click on the '''Structures''' icon [[Image:lab_labview_17.png]] under '''Programming'''. This will bring up the window shown in Figure 10.
###: [[Image:lab_labview_18.gif|frame|center|Figure 10: Programming structure functions.]]
###: [[Image:lab_labview_18.png|frame|center|Figure 10: Programming structure functions.]]
### Click on the '''Case Structure''' icon. Click on the right window to locate it on the back panel. It is a very large object and will have many connections. The 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 value '''''True''''' 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; any control outside of the case structure wired to the question mark determines which case is executed.
### Click on the '''Case Structure''' icon. Click on the right window to locate it on the back panel. It is a very large object and will have many connections. The 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 value '''''True''''' 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; any control outside of the case structure wired to the question mark determines which case is executed.
### On the '''''tools palette''''', chose the Connect Wire icon [[Image:lab_labview_19.gif]]. Connect the slide to the case structure by clicking on the slide object and then on the question mark on the left side of the case structure. The back panel should now look like Figure 11.
### On the '''''tools palette''''', chose the Connect Wire icon [[Image:lab_labview_19.png]]. Connect the slide to the case structure by clicking on the slide object and then on the question mark on the left side of the case structure. The back panel should now look like Figure 11.
###: [[Image:lab_labview_20.jpg|frame|center|Figure 11: Back panel slide to case structure connection.]]
###: [[Image:lab_labview_20.png|frame|center|Figure 11: Back panel slide to case structure connection.]]
### When the case statement is created, it only has two cases. Since there are three operations for the calculator, another case is needed. To add the third case operation, right-click the caption at the top of the case structure and select Add Case After, as shown in Figure 12.
### When the case statement is created, it only has two cases. Since there are three operations for the calculator, another case is needed. To add the third case operation, right-click the caption at the top of the case structure and select Add Case After, as shown in Figure 12.
###: [[Image:lab_labview_21.gif|frame|center|Figure 12: Adding another case.]]
###: [[Image:lab_labview_21.png|frame|center|Figure 12: Adding another case.]]
### Now add the mathematical operations that the calculator should perform for each case. On the '''''functions palette''''', click on the '''Numeric''' icon [[Image:lab_labview_33.gif]] under '''Programming''' from the main '''''functions palette'''''. This will bring up the window shown in Figure 13.
### Now add the mathematical operations that the calculator should perform for each case. On the '''''functions palette''''', click on the '''Numeric''' icon [[Image:lab_labview_33.png]] under '''Programming''' from the main '''''functions palette'''''. This will bring up the window shown in Figure 13.
###: [[Image:lab_labview_23.gif|frame|center|Figure 13: Numeric programming functions.]]
###: [[Image:lab_labview_23.png|frame|center|Figure 13: Numeric programming functions.]]
### Click on the left arrow at the top of the case structure box until the caption for the case structure changes to '''''0'''''. In the '''''Numeric Programming''''' window, click on the Add icon [[Image:lab_labview_26.gif]], and click on a location in the middle of the case structure box to place it.
### Click on the left arrow at the top of the case structure box until the caption for the case structure changes to '''''0'''''. In the '''''Numeric Programming''''' window, click on the Add icon [[Image:lab_labview_26.png]], and click on a location in the middle of the case structure box to place it.
### Click on the right arrow at the top of the case structure box. This should change the caption for the case structure to '''''1'''''. In the '''''Numeric Programming''''' window, click on the Subtract icon [[Image:lab_labview_27.gif]], and click on a location in the middle of the case structure to place it.
### Click on the right arrow at the top of the case structure box. This should change the caption for the case structure to '''''1'''''. In the '''''Numeric Programming''''' window, click on the Subtract icon [[Image:lab_labview_27.png]], and click on a location in the middle of the case structure to place it.
### Click on the right arrow at the top of the case structure box one more time, changing the number in the caption to '''''2'''''. In the '''''Numeric Programming''''' window, click on the Multiply icon [[Image:lab_labview_28.gif]], and click on a location in the middle of the case structure to place it. At this point, each case should look like the ones shown in Figures 14a-c. Check each case by clicking on the left and right arrows to change the case number in the caption.
### Click on the right arrow at the top of the case structure box one more time, changing the number in the caption to '''''2'''''. In the '''''Numeric Programming''''' window, click on the Multiply icon [[Image:lab_labview_28.png]], 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 Figures 14a-c. Check each case by clicking on the left and right arrows to change the case number in the caption.
###: <div style="text-align: center; margin: 0px auto;"><div style="float: left; display: inline;">[[Image:lab_labview_29.gif|frame|none|Figure 14a: Case structure: addition case.]]</div><div style="float: left; display: inline;">[[Image:lab_labview_30.jpg|frame|none|Figure 14b: Case structure: subtraction case.]]</div><div style="float: left; display: inline;">[[Image:lab_labview_31.gif|frame|none|Figure 14c: Case structure: multiplication case.]]</div></div><br clear="both" />
###: <div style="text-align: center; margin: 0px auto;"><div style="float: left; display: inline;">[[Image:lab_labview_29.png|thumb|240px|none|Figure 14a: Case structure: addition case.]]</div><div style="float: left; display: inline;">[[Image:lab_labview_30.png|thumb|240px|none|Figure 14b: Case structure: subtraction case.]]</div><div style="float: left; display: inline;">[[Image:lab_labview_31.png|thumb|240px|none|Figure 14c: Case structure: multiplication case.]]</div></div><br clear="both" />
### Wire the inputs to the calculator. Set the case structure case to zero by clicking on the left arrow until the caption reads '''''0'''''. The triangle inside should be addition, with a plus sign in the middle. Click on the Connect Wire icon [[Image:lab_labview_19.gif]] on the '''''tools palette'''''. Click on the leftmost numeric control on the back panel, and click on the top left side of the operation triangle to wire the first numeric input to the input of the addition operation. Click on the other numeric control on the back panel, and on the left bottom of the addition triangle, establishing the second input. Click on the right side of the triangle, and click on the numeric indicator on the back panel. This will display the output of the addition calculation in the Numeric 3 box on the front panel. The addition function is complete. The back panel should look like Figure 15.
### Wire the inputs to the calculator. Set the case structure case to zero by clicking on the left arrow until the caption reads '''''0'''''. The triangle inside should be addition, with a plus sign in the middle. Click on the Connect Wire icon [[Image:lab_labview_19.png]] on the '''''tools palette'''''. Click on the leftmost numeric control on the back panel, and click on the top left side of the operation triangle to wire the first numeric input to the input of the addition operation. Click on the other numeric control on the back panel, and on the left bottom of the addition triangle, establishing the second input. Click on the right side of the triangle, and click on the numeric indicator on the back panel. This will display the output of the addition calculation in the Numeric 3 box on the front panel. The addition function is complete. The back panel should look like Figure 15.
###: [[Image:lab_labview_32.gif|frame|center|Figure 15: Completed back panel for addition.]]
###: [[Image:lab_labview_32.png|frame|center|Figure 15: Completed back panel for addition.]]
###: '''Note''': Tunnels are created where the input and output wires cross into and out of the case structure; they are signified by squares along the border of the case structure where the wires cross the border. Input wires create complete tunnels, but output wires create tunnels that are incomplete. To complete output tunnels, there must be an output wired to the tunnel for each case of the case structure.
###: '''Note''': Tunnels are created where the input and output wires cross into and out of the case structure; they are signified by squares along the border of the case structure where the wires cross the border. Input wires create complete tunnels, but output wires create tunnels that are incomplete. To complete output tunnels, there must be an output wired to the tunnel for each case of the case structure.
### To complete the other cases, click on the right arrow next to the case structure caption. This will change the caption to '''''1''''', and the subtraction triangle will be in the middle of the case structure. Connect the tunnel from the first numeric control to the top left of the triangle, the tunnel from the second numeric control to the bottom left of the triangle, and the right of the triangle to tunnel to the Numeric 3 box at the bottom of the back panel. 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 was done for the other two cases. The output tunnel is now complete and filled with a solid color. The numeric inputs and outputs are done.
### To complete the other cases, click on the right arrow next to the case structure caption. This will change the caption to '''''1''''', and the subtraction triangle will be in the middle of the case structure. Connect the tunnel from the first numeric control to the top left of the triangle, the tunnel from the second numeric control to the bottom left of the triangle, and the right of the triangle to tunnel to the Numeric 3 box at the bottom of the back panel. 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 was done for the other two cases. The output tunnel is now complete and filled with a solid color. The numeric inputs and outputs are done.
### To illuminate the LED corresponding to each operation, click the left arrow to the left of the caption of the case structure until the caption reads 0, Default. On the '''''functions palette''''', under '''Programming''', click on the '''Boolean''' icon [[Image:lab_labview_36.gif]], which will bring up the '''''Boolean Programming''''' window shown in Figure 16.
### To illuminate the LED corresponding to each operation, click the left arrow to the left of the caption of the case structure until the caption reads 0, Default. On the '''''functions palette''''', under '''Programming''', click on the '''Boolean''' icon [[Image:lab_labview_36.png]], which will bring up the '''''Boolean Programming''''' window shown in Figure 16.
###: [[Image:lab_labview_37.gif|frame|center|Figure 16: Boolean programming functions.]]
###: [[Image:lab_labview_37.png|frame|center|Figure 16: Boolean programming functions.]]
### Add three Boolean constants to the case structure. Since this is Case 0, which corresponds to add, the add indicator must be true, and the other two must be false. Click on the '''''True Constant''''' icon [[Image:lab_labview_42.gif]], and then click inside the case structure on the right side to the left of the add indicator that is outside of the case structure. 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.
### Add three Boolean constants to the case structure. Since this is Case 0, which corresponds to add, the add indicator must be true, and the other two must be false. Click on the '''''True Constant''''' icon [[Image:lab_labview_42.png]], and then click inside the case structure on the right side to the left of the add indicator that is outside of the case structure. Select the '''''False Constant''''' icon [[Image:lab_labview_43.png]] and place it inside the case structure on the right side next to the subtract and multiply indicators.
### To wire the constants to their respective indicators, 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. Do the same for the other two constants and their corresponding indicators. Three incomplete output tunnels have been formed. The add operation is complete.
### To wire the constants to their respective indicators, click on the '''''Connect Wire''''' icon [[Image:lab_labview_19.png]] 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. Do the same for the other two constants and their corresponding indicators. Three incomplete output tunnels have been formed. The add operation is complete.
### Click on the right arrow next to the case structure icon. The caption should now show '''''1'''''. To have the subtract indicator illuminate for this case. Place a '''''True Constant''''' inside the case structure on the right side to the left of the subtract LED. Place a '''''False Constant''''' inside the case structure on the right side 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 output tunnel. Do the same for the other two constants and their corresponding output tunnels. The subtract operation is complete.
### Click on the right arrow next to the case structure icon. The caption should now show '''''1'''''. To have the subtract indicator illuminate for this case. Place a '''''True Constant''''' inside the case structure on the right side to the left of the subtract LED. Place a '''''False Constant''''' inside the case structure on the right side 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.png]] on the '''''tools palette'''''. Click on the right side of the top constant inside the case structure and connect it to the top output tunnel. Do the same for the other two constants and their corresponding output tunnels. The subtract operation is complete.
### To finish the calculator, click on the right arrow next to the case structure icon. The caption should now show '''''2'''''. The multiplication indicator should illuminate for this case. Add a '''''True Constant''''' to the right side of the case structure to the left of the multiplication LED. Place a '''''False Constant''''' 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 output tunnel. Do the same for the other two constants and their corresponding output tunnels. The multiply operation is complete and all output tunnels have been filled.
### To finish the calculator, click on the right arrow next to the case structure icon. The caption should now show '''''2'''''. The multiplication indicator should illuminate for this case. Add a '''''True Constant''''' to the right side of the case structure to the left of the multiplication LED. Place a '''''False Constant''''' 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.png]] on the '''''tools palette'''''. Click on the right side of the top constant inside the case structure and connect it to the top output tunnel. Do the same for the other two constants and their corresponding output tunnels. The multiply operation is complete and all output tunnels have been filled.
# The VI must be tested:
# The VI must be tested:
## Enter different input numbers through the control icon on the front panel.
## Enter different input numbers through the control icon on the front panel.
Line 143: Line 141:
## Make sure the correct LED lights up for the operation.
## Make sure the correct LED lights up for the operation.
## Have the TA test the VI.
## Have the TA test the VI.
#: [[Image:lab_labview_50.gif|frame|center|Figure 17: Completed and working VI.]]
#: [[Image:lab_labview_50.png|frame|center|Figure 17: Completed and working VI.]]
# Once testing is completed, take a screenshot the VI.
# Once testing is completed, take a screenshot the VI.
# Save the VI.
# Save the VI.
Line 169: Line 167:
Build a VI that simulates a lighting system in a house with four rooms. The design must include four lights (LEDs) and at least five switches &mdash; 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.
Build a VI that simulates a lighting system in a house with four rooms. The design must include four lights (LEDs) and at least five switches &mdash; 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.
# The '''''front panel''''' of the program should include five switches and four LEDs.
# The '''''front panel''''' of the program should include five switches and four LEDs.
# While there are several ways to implement the '''''back panel''''', one suggestion is to use a separate Boolean '''''case structure''''' for each switch. This will also make it easier to interact with the LEDs on the NI-ELVIS board.
# The '''''back panel''''' requires a '''''case structure''''' for the master switch to turn off all the lights.
# In order to control the LEDs on the NI-ELVIS board, a '''''NI ELVISmx Digital Writer''''' node is required on the back panel.
# In order to control the LEDs on the NI-ELVIS board, a '''''NI ELVISmx Digital Writer''''' node is required on the back panel.
## To access the '''''NI ELVISmx Digital Writer''''' node, click on '''''Measurement I/O''''' on the '''''functions palette''''', open '''''NI ELVISmx''''', and select '''''Digital Writer'''''. (see Figure 18)
## To access the '''''NI ELVISmx Digital Writer''''' node, click on '''''Measurement I/O''''' on the '''''functions palette''''', open '''''NI ELVISmx''''', and select '''''Digital Writer'''''. (see Figure 18)
##: [[Image:lab_labview_56.gif|frame|center|Figure 18: NI ELVISmx measurement I/O functions.]]
##: [[Image:lab_labview_56.png|frame|center|Figure 18: NI ELVISmx measurement I/O functions.]]
## Once these are placed on the '''''back panel''''', the '''NI ELVISmx Digital Writer''' dialog box will open. Click OK.
## Once these are placed on the '''''back panel''''', the '''NI ELVISmx Digital Writer''' dialog box will open. Click OK.
## The '''''NI ELVISmx Digital Writer''''' is used for writing information to the NI-ELVIS board. For the purposes of this lab, only two pieces of information need to be presented to the '''Digital Writer''' node: '''DO Lines''' and '''Lines to Write'''.
## The '''''NI ELVISmx Digital Writer''''' is used for writing information to the NI-ELVIS board. For the purposes of this lab, only two pieces of information need to be presented to the '''Digital Writer''' node: '''DO Lines''' and '''Lines to Write'''.
##: [[Image:lab_labview_58.gif|frame|center|Figure 20: NI ELVISmx Digital Writer.]]
##: [[Image:lab_labview_58.png|frame|center|Figure 19: NI ELVISmx Digital Writer.]]
### '''DO Lines (Boolean array)''': This determines which DIO rows on the NI-ELVIS board will be activated (in other words, which LEDs will light up).
### '''DO Lines (Boolean array)''': This determines which DIO rows on the NI-ELVIS board will be activated (in other words, which LEDs will light up).
### '''Lines to Write (ring constant)''': This determines which eight DIO rows can work on the NI-ELVIS board.
### '''Lines to Write (ring constant)''': This determines which eight DIO rows can work on the NI-ELVIS board.
#### For the purposes of this lab, DIO lines '''0&ndash;7''' will be utilized. To establish this setting, right-click the '''Lines to Write''' row on the '''''NI ELVISmx Digital Writer''''', select ''Create'', followed by ''Constant''. The '''Operate Value''' tool can be used to manipulate this value. By default, it is set to '''0&ndash;7'''.
#### For the purposes of this lab, DIO lines '''0&ndash;7''' will be utilized. To establish this setting, right-click the '''Lines to Write''' row on the '''''NI ELVISmx Digital Writer''''', select ''Create'', followed by ''Constant''. The '''Operate Value''' tool can be used to manipulate this value. By default, it is set to '''0&ndash;7'''.
## The switches should be wired to a '''''Build Array''''' icon, along with four '''False''' constants. Conceptually, think of a vehicle that only departs when all the seats are filled. In this case, the ''DO Lines'' is a road only allows vehicles with eight passengers to travel to the NI-ELVIS board. So in order for information to flow from the VI to the NI-ELVIS board, '''Build Array''' must provide a vehicle (i.e., an array) with eight passengers or outputs (i.e., the four Boolean switches and four '''False''' constants). '''''Build Array''''' can be found under '''Programming''' on the '''''functions palette''''' by clicking '''Array'''. (see Figure 19)
## The switches should be wired to a '''''Build Array''''' icon, along with four '''False''' constants. Conceptually, think of a vehicle that only departs when all the seats are filled. In this case, the ''DO Lines'' is a road only allows vehicles with eight passengers to travel to the NI-ELVIS board. So in order for information to flow from the VI to the NI-ELVIS board, '''Build Array''' must provide a vehicle (i.e., an array) with eight passengers or outputs (i.e., the four Boolean switches and four '''False''' constants). '''''Build Array''''' can be found under '''Programming''' on the '''''functions palette''''' by clicking '''Array'''. (see Figure 20)
##: [[Image:lab_labview_67.jpg|frame|center|Figure 19: Array programming functions.]]
##: [[Image:lab_labview_67.png|frame|center|Figure 20: Array programming functions.]]
## Also keep in mind that if the master switch is off, then all of the LEDs connected to the NI-ELVIS board should shut off as well.
## Also keep in mind that if the master switch is off, then all of the LEDs connected to the NI-ELVIS board should shut off as well.
# In order for the LEDs on the NI-ELVIS board to light up, wires must connect the DIO lines (rows 0&ndash;23) directly to the LEDs on the NI-ELVIS board (rows 35&ndash;42).
# In order for the LEDs on the NI-ELVIS board to light up, wires must connect the DIO lines (rows 0&ndash;23) directly to the LEDs on the NI-ELVIS board (rows 35&ndash;42).
Line 191: Line 189:


=== How to get a slide control: ===
=== How to get a slide control: ===
# On the Controls palette, select the '''Num Ctrls''' icon [[Image:lab_labview_2.gif]]
# On the Controls palette, select the '''Num Ctrls''' icon [[Image:lab_labview_2.png]]
# Select Horizontal Pointer Slide
# Select Horizontal Pointer Slide
# Click on the front panel to place the slide on the front panel at the location you select
# Click on the front panel to place the slide on the front panel at the location you select


=== How to get an LED indicator: ===
=== How to get an LED indicator: ===
# On the Controls palette, select the '''LEDs''' icon [[Image:lab_labview_8.gif]].
# On the Controls palette, select the '''LEDs''' icon [[Image:lab_labview_8.png]].
# Select the '''Round LED''' icon from the icons shown.
# Select the '''Round LED''' icon from the icons shown.
# Click on the left window to place the LED on the front panel at the location you select.
# Click on the left window to place the LED on the front panel at the location you select.
# Rename the LED with a label that indicates what the LED stands for. To rename the LED, click on the '''Edit Text''' icon [[Image:lab_labview_10.gif]] on the '''Tools palette'''. Then click on the 'Boolean' label on each LED and replace it with the proper text.
# Rename the LED with a label that indicates what the LED stands for. To rename the LED, click on the '''Edit Text''' icon [[Image:lab_labview_10.png]] on the '''Tools palette'''. Then click on the 'Boolean' label on each LED and replace it with the proper text.


=== How to get a Numeric Input Control ===
=== How to get a Numeric Input Control ===
Line 206: Line 204:


=== How to get a Numeric Indicator Output ===
=== How to get a Numeric Indicator Output ===
# On the Controls palette, click on the '''Num Inds''' icon [[Image:lab_labview_11.gif]]. This will bring up the window shown in Figure 9.
# On the Controls palette, click on the '''Num Inds''' icon [[Image:lab_labview_11.png]]. This will bring up the window shown in Figure 9.
# Click on the '''Num Ind''' icon and click on the front panel location where you want the indicator.
# Click on the '''Num Ind''' icon and click on the front panel location where you want the indicator.


Line 213: Line 211:
=== How to define a case structure ===
=== How to define a case structure ===
# 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.
# 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.
#: [[Image:lab_labview_15.gif|frame|center|Figure 29a: How to bring up the Functions Palette]]
#: [[Image:lab_labview_15.png|frame|center|Figure 29a: How to bring up the Functions Palette]]
#: [[Image:lab_labview_51.gif|frame|center|Figure 29b: Functions Palette]]
#: [[Image:lab_labview_51.png|frame|center|Figure 29b: Functions Palette]]
# Clink on the '''Exec Ctrl''' icon. This will bring up the '''''Exec Ctrl''''' window, shown in Figure 13.
# Clink on the '''Exec Ctrl''' icon. This will bring up the '''''Exec Ctrl''''' window, shown in Figure 13.
# Click on the '''Case Structure''' icon. Click on the right window to locate it on the back panel.
# Click on the '''Case Structure''' icon. Click on the right window to locate it on the back panel.
Line 221: Line 219:


=== How to define an arithmetic operation ===
=== How to define an arithmetic operation ===
# On the '''''Functions Palette''''', click on the '''Arith/Compare''' icon [[Image:lab_labview_33.gif]]. will bring up the Arith/Compare window shown in Figure 17.
# On the '''''Functions Palette''''', click on the '''Arith/Compare''' icon [[Image:lab_labview_33.png]]. will bring up the Arith/Compare window shown in Figure 17.
# On the Arith/Compare window, click on the '''Numeric''' icon [[Image:lab_labview_24.gif]]. This will bring up the '''''Express Numeric''''' window shown in Figure 18.
# On the Arith/Compare window, click on the '''Numeric''' icon [[Image:lab_labview_24.png]]. This will bring up the '''''Express Numeric''''' window shown in Figure 18.
# In the '''''Express Numeric''''' Window, click on the icon for the arithmetic operation you want. Click on the front panel location where the icon goes.
# In the '''''Express Numeric''''' Window, click on the icon for the arithmetic operation you want. Click on the front panel location where the icon goes.


=== How to define Boolean constants (usually used to illuminate LEDs) ===
=== How to define Boolean constants (usually used to illuminate LEDs) ===
# On the '''''Functions Palette''''', click on the '''Arith/Compare''' icon [[Image:lab_labview_33.gif]]. This will bring up the '''''Arith/Compare''''' window.
# On the '''''Functions Palette''''', click on the '''Arith/Compare''' icon [[Image:lab_labview_33.png]]. This will bring up the '''''Arith/Compare''''' window.
# On the '''''Arith/Compare''''' window, click on the '''Numeric''' icon [[Image:lab_labview_24.gif]]. This will bring up the '''''Express Numeric''''' window shown in 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 '''''Arith/Compare''''' window, click on the '''Numeric''' icon [[Image:lab_labview_24.png]]. This will bring up the '''''Express Numeric''''' window shown in Figure 18. On the '''''Express Numeric''''' window, click the upward facing arrow. This will bring up the '''''Arithmetic and Comparison''''' window shown in Figure 21.
# On the '''''Arithmetic and Comparison''''' window, click on the Boolean icon [[Image:lab_labview_36.gif]], which will bring up the '''''Express Boolean''''' window shown in Figure 22.
# On the '''''Arithmetic and Comparison''''' window, click on the Boolean icon [[Image:lab_labview_36.png]], which will bring up the '''''Express Boolean''''' window shown in Figure 22.
# 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.
# Click on the True Constant icon [[Image:lab_labview_42.png]] or False Constant icon [[Image:lab_labview_43.png]], and then clicking the location of the constant on the back panel.


=== How to wire things ===
=== How to wire things ===
# 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.
# 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.
# On the Tools Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.gif]].
# On the Tools Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.png]].
# 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.
# 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.



Revision as of 03:16, 22 January 2014

Objectives

The experimental objective of this lab is to design three systems using LabVIEW: a digital calculator, a lighting system for a building, and a thermal control system that automatically operates heating and cooling equipment.

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. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. The logic of graphical programming will be shown during the course of this lab.

Overview

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

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

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

The back panel, which is a block diagram, contains the graphical source code. All of the objects placed on the front panel will appear on the back panel as terminals. The back panel also contains structures and functions that perform operations on controls and supply data to indicators. Structures and functions are found on the functions palette and can be placed on the back panel. Collectively, controls, indicators, structures, and functions are referred to as nodes. Nodes are connected to one another using wires. 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.

In any programming language, structures are used to create conditions. In LabVIEW, structures are accessed by opening the functions palette and selecting Structures. The following are some examples of structures:

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

The data acquisition and control (DAC) board is LabVIEW's physical interface with the outside world. Keep in mind that National Instruments offers different hardware solutions to meet clients' individual needs. Using the available hardware, the only digital output port available is Port 0. This will be important when setting up the DAQ Assistant.

Some useful key shortcuts when working in the LabVIEW environment are:

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

Assignment

Individual Lab Report

A zip file including all LabVIEW programs (.vi) must be submitted to the EG Website. To create a zip file, read the page How to Compress Your Files in the Instructional Presentations section.

Follow the lab report guidelines laid out in the page called Specifications for Writing Your Lab Reports in the Technical Communication section of this manual. The following discussion points should be addressed in the appropriate section of the lab 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 a DAC board is.
  • Were the objectives of the experiment achieved? If not why?
  • Describe the advantages and disadvantages of using LabVIEW.
  • Suggest some improvements of how the lab could have be conducted better.

IMPORTANT: Because the procedural elements in this lab are extensive, please include only the procedures employed to build Design 2, the heating and cooling system in the lab report. Do not document the procedures followed to build Design 1: the simple calculator, or Design 3: the lighting system.

Note: Though the Procedure section is limited to the heating and cooling system, discuss ALL the designs in the Data/Observations, and Conclusion sections of the lab report.

Explain the steps taken to create the heating and cooling system in the Procedure section. 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, show the screenshots in the lab reports showing the VIs that were designed. Look at the Online Manual under "Instructional Web Pages" for instructions on how to take a screen shot and use it.

Team PowerPoint Presentation (Sections HS1 & HS2 Only)

For Sections A, B, C, D, E, F, and G: there is no presentation for Lab 4; Milestone 1 presentations are due.

Follow the presentation guidelines laid out in the page called EG1003 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.

Materials and Equipment

  • Lab PC
  • LabVIEW software
  • NI-ELVIS II+ prototyping board

Procedure

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

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

For help with the operation of any LabVIEW icon, select Help from the main menu bar, choose Show Context Help, and click the icon for the operation that is unclear. It will be explained in the open window.

The overall approach for each of these projects is to place items on the front panel that the user will see and interact with. The corresponding items on the back panel will make the device work if the wiring is correct.

Note: Some tasks will be repeated and the same icons will be used. A LabVIEW digest at the end of this lab has references for faster navigation.

Design 1: Simple Calculator

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

  1. The front panel must contain:
    1. One slide to control the arithmetic operation to be performed. The instructions are:
      1. Select the Numeric icon Lab labview 2.png under Modern on the controls palette (see Figure 2). This will bring up the window shown in Figure 3.
        Figure 2: Controls palette.
        Figure 3: Modern numeric controls.
      2. Select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide on the front panel at any location.
        Note: The slide may be moved by clicking on it and holding down the left mouse button to drag the control to a preferred location. When correctly located, let go of the left mouse button. This will work for all items in both the front and back panels.
        Note: When items are placed on the front panel (left window), symbols corresponding to each item will appear on the back panel (right window). When the front panel is complete, the items on the back panel will be wired to make the calculator work.
      3. Click on the number 10 and change it to 2. Now the slide control will look like Figure 4.
        Figure 4: Slide control with range changed from 10 to 2.
      4. Right click on the slide to bring up a pull down menu. Select Representation, and choose the I8 icon. Figure 5 shows what the pull down menus look like and the I8 icon. This completes the slide control on the front panel.
        Figure 5: Data type representation pull down menu.
    2. Three Boolean indicators to specify the operation selected. The instructions are:
      1. On the controls palette, select the Boolean icon Lab labview 8.png under Modern. This will bring up the window shown in Figure 6.
        Figure 6: Modern boolean controls.
      2. Select the Round LED icon from the icons shown. Click on the left window to place the LED on the front panel at a specific location. 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 created so there are three lights in a row under the slide.
      3. Rename the three LEDs to correspond to the functions the calculator will be performing: add, subtract, and multiply. To rename each LED, click on the Edit Text icon Lab labview 10.png on the tools palette. Then click on the labels on each LED and replace it with the proper text: "Add" for the left light, "Subtract" for the center light, and "Multiply" for the right light.
    3. Two numeric controls will allow the user to input data from the keyboard. The instructions are:
      1. On the controls palette, click on the Numeric icon under Modern. This will bring up the window shown in Figure 3 again.
      2. Click on the Numeric Control 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 that allows data input. Click the Numeric Control icon again, and place another numeric control on the right side of the slide.
    4. A numeric indicator to display the output. The instructions are:
      1. On the controls palette, click on the Numeric Indicator icon and click on the left window centered below the three lights. This numeric indicator will display the answer from the calculator.
        Note: This numeric indicator, used for output, is a different type of object from the two numeric controls (which are for input) that was constructed earlier in Item c.
      2. The finished front panel should look like Figure 7:
        Figure 7: Finished front panel.
    As stated earlier, on the back panel there are icons corresponding to everything that was placed on the front panel. They will be arranged, additional objects will be added, and they will be wired to make the calculator work.
  2. The back panel must contain:
    1. At least one case statement to control the arithmetic operations. This case statement will be the heart of the calculator. The instructions are:
      1. Drag all the Boolean nodes to the right edge of the window and all numeric controls and indicator to the bottom of the window. Place the slide node on the left edge of the window. This will leave a large area in the middle that will be filled in at the next few steps. The back panel should look like Figure 8.
        Figure 8: Rearranged back panel.
      2. In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose Functions Palette. This will bring up the functions palette, shown in Figure 9.
        Figure 9: Functions palette.
      3. Click on the Structures icon Lab labview 17.png under Programming. This will bring up the window shown in Figure 10.
        Figure 10: Programming structure functions.
      4. Click on the Case Structure icon. Click on the right window to locate it on the back panel. It is a very large object and will have many connections. The 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 value True 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; any control outside of the case structure wired to the question mark determines which case is executed.
      5. On the tools palette, chose the Connect Wire icon Lab labview 19.png. Connect the slide to the case structure by clicking on the slide object and then on the question mark on the left side of the case structure. The back panel should now look like Figure 11.
        Figure 11: Back panel slide to case structure connection.
      6. When the case statement is created, it only has two cases. Since there are three operations for the calculator, another case is needed. To add the third case operation, right-click the caption at the top of the case structure and select Add Case After, as shown in Figure 12.
        Figure 12: Adding another case.
      7. Now add the mathematical operations that the calculator should perform for each case. On the functions palette, click on the Numeric icon Lab labview 33.png under Programming from the main functions palette. This will bring up the window shown in Figure 13.
        Figure 13: Numeric programming functions.
      8. Click on the left arrow at the top of the case structure box until the caption for the case structure changes to 0. In the Numeric Programming window, click on the Add icon Lab labview 26.png, and click on a location in the middle of the case structure box to place it.
      9. Click on the right arrow at the top of the case structure box. This should change the caption for the case structure to 1. In the Numeric Programming window, click on the Subtract icon Lab labview 27.png, and click on a location in the middle of the case structure to place it.
      10. Click on the right arrow at the top of the case structure box one more time, changing the number in the caption to 2. In the Numeric Programming window, click on the Multiply icon Lab labview 28.png, 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 Figures 14a-c. Check each case by clicking on the left and right arrows to change the case number in the caption.
        Figure 14a: Case structure: addition case.
        Figure 14b: Case structure: subtraction case.
        Figure 14c: Case structure: multiplication case.

      11. Wire the inputs to the calculator. Set the case structure case to zero by clicking on the left arrow until the caption reads 0. The triangle inside should be addition, with a plus sign in the middle. Click on the Connect Wire icon Lab labview 19.png on the tools palette. Click on the leftmost numeric control on the back panel, and click on the top left side of the operation triangle to wire the first numeric input to the input of the addition operation. Click on the other numeric control on the back panel, and on the left bottom of the addition triangle, establishing the second input. Click on the right side of the triangle, and click on the numeric indicator on the back panel. This will display the output of the addition calculation in the Numeric 3 box on the front panel. The addition function is complete. The back panel should look like Figure 15.
        Figure 15: Completed back panel for addition.
        Note: Tunnels are created where the input and output wires cross into and out of the case structure; they are signified by squares along the border of the case structure where the wires cross the border. Input wires create complete tunnels, but output wires create tunnels that are incomplete. To complete output tunnels, there must be an output wired to the tunnel for each case of the case structure.
      12. To complete the other cases, click on the right arrow next to the case structure caption. This will change the caption to 1, and the subtraction triangle will be in the middle of the case structure. Connect the tunnel from the first numeric control to the top left of the triangle, the tunnel from the second numeric control to the bottom left of the triangle, and the right of the triangle to tunnel to the Numeric 3 box at the bottom of the back panel. 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 was done for the other two cases. The output tunnel is now complete and filled with a solid color. The numeric inputs and outputs are done.
      13. To illuminate the LED corresponding to each operation, click the left arrow to the left of the caption of the case structure until the caption reads 0, Default. On the functions palette, under Programming, click on the Boolean icon Lab labview 36.png, which will bring up the Boolean Programming window shown in Figure 16.
        Figure 16: Boolean programming functions.
      14. Add three Boolean constants to the case structure. Since this is Case 0, which corresponds to add, the add indicator must be true, and the other two must be false. Click on the True Constant icon Lab labview 42.png, and then click inside the case structure on the right side to the left of the add indicator that is outside of the case structure. Select the False Constant icon Lab labview 43.png and place it inside the case structure on the right side next to the subtract and multiply indicators.
      15. To wire the constants to their respective indicators, click on the Connect Wire icon Lab labview 19.png 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. Do the same for the other two constants and their corresponding indicators. Three incomplete output tunnels have been formed. The add operation is complete.
      16. Click on the right arrow next to the case structure icon. The caption should now show 1. To have the subtract indicator illuminate for this case. Place a True Constant inside the case structure on the right side to the left of the subtract LED. Place a False Constant inside the case structure on the right side to the left of the add LED, and again to the left of the multiply LED. Click on the Connect Wire icon Lab labview 19.png on the tools palette. Click on the right side of the top constant inside the case structure and connect it to the top output tunnel. Do the same for the other two constants and their corresponding output tunnels. The subtract operation is complete.
      17. To finish the calculator, click on the right arrow next to the case structure icon. The caption should now show 2. The multiplication indicator should illuminate for this case. Add a True Constant to the right side of the case structure to the left of the multiplication LED. Place a False Constant inside the right side of the case structure to the left of the add LED, and again to the left of the subtraction LED. Click on the Connect Wire icon Lab labview 19.png on the tools palette. Click on the right side of the top constant inside the case structure and connect it to the top output tunnel. Do the same for the other two constants and their corresponding output tunnels. The multiply operation is complete and all output tunnels have been filled.
  3. The VI must be tested:
    1. Enter different input numbers through the control icon on the front panel.
    2. Make sure the output is correct.
    3. Make sure the correct LED lights up for the operation.
    4. Have the TA test the VI.
    Figure 17: Completed and working VI.
  4. Once testing is completed, take a screenshot the VI.
  5. Save the VI.

Design 2: Heating and Cooling System

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

  • The air conditioner is turned on when the temperature is above 80°F.
  • The heater is turned on when the temperature is less than 60°F.
  • The heater and the air conditioner are turned off when the temperature is between 60°F and 80°F.
  1. The front panel must contain:
    1. Three LEDs: one to represent the AC, one to represent the heater, and one to show that the system is being operated manually.
    2. Three switches: one to control the AC, one to control the heater, and one to control manual or automatic operation.
    3. A thermometer to set the temperature of the system. By default, the thermometer is an indicator; right-click on it and select Change to control. The thermometer should be set to 70°F.
  2. The back panel must contain:
    1. A Boolean case statement to control the manual and automatic operation of the AC and the heater.
  3. After the VI is completed, it must be tested:
    1. Using the slide bar on the thermometer, change the system temperature. Make sure the AC and heat come on as directed.
    2. Test the program's manual operation by turning the manual switch on and then turning the AC and heat switches on. Each of the LEDs should light up when its corresponding switch is in the On position.
    3. Have the TA test the VI.
  4. Once testing is completed, take a screenshot of the VI.
  5. Save the VI.

Design 3: Lighting System

Build a VI that simulates a lighting system in a house with four rooms. The design must include 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 include five switches and four LEDs.
  2. The back panel requires a case structure for the master switch to turn off all the lights.
  3. In order to control the LEDs on the NI-ELVIS board, a NI ELVISmx Digital Writer node is required on the back panel.
    1. To access the NI ELVISmx Digital Writer node, click on Measurement I/O on the functions palette, open NI ELVISmx, and select Digital Writer. (see Figure 18)
      Figure 18: NI ELVISmx measurement I/O functions.
    2. Once these are placed on the back panel, the NI ELVISmx Digital Writer dialog box will open. Click OK.
    3. The NI ELVISmx Digital Writer is used for writing information to the NI-ELVIS board. For the purposes of this lab, only two pieces of information need to be presented to the Digital Writer node: DO Lines and Lines to Write.
      Figure 19: NI ELVISmx Digital Writer.
      1. DO Lines (Boolean array): This determines which DIO rows on the NI-ELVIS board will be activated (in other words, which LEDs will light up).
      2. Lines to Write (ring constant): This determines which eight DIO rows can work on the NI-ELVIS board.
        1. For the purposes of this lab, DIO lines 0–7 will be utilized. To establish this setting, right-click the Lines to Write row on the NI ELVISmx Digital Writer, select Create, followed by Constant. The Operate Value tool can be used to manipulate this value. By default, it is set to 0–7.
    4. The switches should be wired to a Build Array icon, along with four False constants. Conceptually, think of a vehicle that only departs when all the seats are filled. In this case, the DO Lines is a road only allows vehicles with eight passengers to travel to the NI-ELVIS board. So in order for information to flow from the VI to the NI-ELVIS board, Build Array must provide a vehicle (i.e., an array) with eight passengers or outputs (i.e., the four Boolean switches and four False constants). Build Array can be found under Programming on the functions palette by clicking Array. (see Figure 20)
      Figure 20: Array programming functions.
    5. Also keep in mind that if the master switch is off, then all of the LEDs connected to the NI-ELVIS board should shut off as well.
  4. In order for the LEDs on the NI-ELVIS board to light up, wires must connect the DIO lines (rows 0–23) directly to the LEDs on the NI-ELVIS board (rows 35–42).

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.

LabVIEW Digest of Common Tasks

Front Panel Controls and Indicators

How to get a slide control:

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

How to get an LED indicator:

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

How to get a Numeric Input Control

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

How to get a Numeric Indicator Output

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

Back Panel Objects

How to define a case structure

  1. In the block diagram (back panel) of LabVIEW, go to the menu bar, select window, and choose "Show Functions Palette", just as shown on Figure 29a. This will bring up the Functions Palette, shown in Figure 29b.
    File:Lab labview 15.png
    Figure 29a: How to bring up the Functions Palette
    File:Lab labview 51.png
    Figure 29b: Functions Palette
  2. Clink on the Exec Ctrl icon. This will bring up the Exec Ctrl window, shown in Figure 13.
  3. Click on the Case Structure icon. Click on the right window to locate it on the back panel.
  4. The default is two cases: 0 and 1. To add more cases, right-click anywhere on the case structure and select Add Case After, as shown in Figure 15.
  5. Define what happens for each case. On each side of the caption are arrows that will count the case number up and down. Choose the case number you want to define and then fill in the case structure with whatever needs to be done for this case. Make sure every case is fully defined. It is very easy to forget things.

How to define an arithmetic operation

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

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

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

How to wire things

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

Footnotes

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