Difference between revisions of "Introduction to LabVIEW"

From EG1004 Lab Manual
Jump to: navigation, search
Line 94: Line 94:
# Run the VI
# Run the VI


== Design 3: Lighting System ==
== Design 2: 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.
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.
# 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.

Revision as of 03:31, 18 January 2018

3D Printing and Prototyping Video

General Engineering has created a video that covers the fundamental concepts of 3D printing for the semester-long design project: 3D Printing and Prototyping Video. This video provides the fundamental principles behind the engineering design process and will help determine the best practices for 3D printing objects to complete the semester-long design project. Material covered in the video will be on the lab 4 quiz. Viewing the video is a mandatory pre-lab assignment.

MakerSpace Orientation

Part of this lab session will be used to take a tour of the MakerSpace. This orientation will include basic training on some of the MakerSpace equipment you will be able to use in the future.

Objectives

The experimental objective of this lab is to design two systems using LabVIEW: a thermal control system and a lighting 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 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 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 the 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

National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI-ELVIS) board is one solution LabVIEW can utilize to physically interface with the outside world. Keep in mind that National Instruments offers different hardware solutions to meet clients' individual needs.

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

Materials and Equipment

  • A lab PC
  • LabVIEW software
  • An NI-ELVIS II+ prototyping board
  • Wires

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.

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 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: Heating and Cooling System

Build a VI that simulates a heating and cooling system. The system must be controlled 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

The VI will 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.

  1. Include the pre-written sub-VIs provided to interface with the circuit on the NI-ELVIS board.
    1. Insert the sub-VIs into the back panel by right-clicking on the back panel and clicking on Select A VI from the context menu that pops up. Open the Heating Control, Cooling Control, and Temperature Reading VIs located in the EG MENU shortcut on the Lab PC desktop
    2. Wire the output tunnels of the case structure for the heating and cooling indicators to the green terminals labeled Heat on the Heating Control and Cooling on the Cooling Control, respectively
    3. Connect the orange terminal labeled Result on the Temperature Reading node to the comparison operators used in the Automatic case. The Temperature Reading sub-VI will effectively replace the thermometer control
  2. Change the thermometer node to an indicator and connect the Result terminal on the Temperature Reading sub-VI to the thermometer. Since the Temperature Reading sub-VI replaces the thermometer, the thermometer will be used to monitor the temperature being read.
  3. Define a device constant for each of the pre-written sub-VIs. The device constant will determine the device(s) the sub-VIs read from and write to.
    1. Right-click on the purple Device Name or device name terminals on the sub-VI nodes using the Connect Wire tool. Mouse over Create on the context menu, and select Constant
    2. Verify that all three device constants are equivalent
  4. Ask the TA to check over the modifications. If correct, the TA will supply an NI-ELVIS board with a pre-built circuit.
  5. Connect the heat cube and its circuit to the NI-ELVIS board.
    1. Using two 100,000 Ω resistors (Brown, Black, Yellow), insert one end of each resistor into AIGND (row 18) of the NI-ELVIS board
    2. Using a wire, connect the AI 7+ port (row 15) to the screw terminal 1 port (row 46)
    3. Using a wire, connect the AI 7- port (row 16) to the screw terminal 2 port (row 47)
    4. 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)
    5. Insert the positive and negative wires from the fan into Variable Power Supplies SUPPLY+ (row 48) and Variable Power Supplies GROUND (row 49) at the lower-left-hand corner of the NI-ELVIS board
    6. Connect the positive wire from the heating pad to DC +5V (row 54) on the lower-right-hand corner of the NI-ELVIS board
    7. 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
    8. 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
      Figure 18: Mosfet.
  6. Attach the USB cable to the NI-ELVIS board, and power it. The device constants on the back panel should update to reference the NI-ELVIS device
  7. Run the VI

Design 2: 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.

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

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 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 an NI-ELVIS board is
  • Were the objectives of the experiment achieved? If not why?
  • Describe the advantages and disadvantages of using LabVIEW
  • Suggest some improvements for the lab procedure

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

Note: 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, show 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.

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.

Team PowerPoint Presentation (EGED I Only)

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.

LabVIEW Digest of Common Tasks

Front Panel Controls and Indicators

How to get a slide control:

  1. On the Controls Palette, select the Numeric icon Lab labview 2.png under the Modern category
  2. Select Horizontal Pointer Slide
  3. Click on the front panel to place the slide on the front panel at a specific location

How to get an LED indicator:

  1. On the Controls Palette, select the Boolean icon Lab labview 8.png under the Modern category
  2. Select the Round LED icon from the icons shown
  3. Click on the front panel to place the LED at the location selected
  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 default 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 Numeric icon under the Modern category
  2. Click on the Numeric Control icon and click on the location the control is to be placed

How to get a Numeric Indicator Output

  1. On the Controls Palette, click on the Numeric icon under the Modern category.
  2. Click on the Numeric Indicator icon and click on the front panel location where the indicator is to be placed

Back Panel Objects

How to define a case structure

  1. On the Functions Palette, click on the Structures icon under the Programming category.
  2. Click on the Case Structure icon. Click on the back panel to place it at the desired location.
  3. By default, the case structure assumes it is being controlled by a Boolean control. What controls the case structure is any control that is wired to the question mark along the border. When being controlled by a Boolean control, the default cases are False and True; when being controlled by a numeric control, the default cases are 0 and 1. To add more cases, right-click anywhere on the Case Structure and select Add Case After.
  4. Define what happens for each case. Use arrows on each side of the caption to switch between cases. Switch to the case that is to be defined and fill the case structure with whatever needs to be done for that case. Make sure each case is fully defined. When output wires cross the border of the case structure, incomplete tunnels will be created. To complete the tunnels, an output wire must be wired to the tunnel for each case.

How to define an arithmetic operation

  1. On the Functions Palette, click on the Numeric icon Lab labview 33.png under the Programming category
  2. On the Numeric Programming window, click on the icon for the desired arithmetic operation. 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 Boolean icon Lab labview 36.png under the Programming category.
  2. Click on the True Constant icon Lab labview 42.png or False Constant icon Lab labview 43.png, and then click the location of the constant on the back panel

How to wire

  1. Objects have inputs on their left side and outputs on their right side. The output (right side) of one object is always wired 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 is to be wired from. Click the desired object input 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