PHY 351/651 LABORATORY 1 Introduction to LabVIEW

Similar documents
Data Acquisition Laboratory

Small rectangles (and sometimes squares like this

PHYS 5061 Lab 1: Introduction to LabVIEW

Step-by-Step Data Acquisition Part II Exercise 2: Generating an Analog Output Waveform

2 Lab 2: LabVIEW and Control System Building Blocks

Using LabVIEW in Instrumentation and Control Course

Hands-On Introduction to. LabVIEW. for Scientists and Engineers. Second Edition. John Essick. Reed College OXFORD UNIVERSITY PRESS

Engineering Project-I. Module 1: Familiarization of LabVIEW and the Vernier Toolkit

Homework Assignment 9 LabVIEW tutorial

Introduction to Labview and Temperature Measurement

1. Learn about LabView software and its different components

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW

INTRODUCTION TO LABVIEW

c01.qxd p /18/01 11:03 AM Page 1 Fundamentals

Hands-on Lab 2: LabVIEW NI-DAQ Basics 2

Page 1 of 6. ME 3200 Mechatronics I Laboratory Lab 2: LabView Computer Systems. Introduction

ENGR 1000, Introduction to Engineering Design

Linear Control Systems LABORATORY

Ch En 475: Introduction to Instrumentation and Signal Processing with Labview

Lab Exercise 2: Data Acquisition with NI LabVIEW

Strain and Force Measurement

Computer Interfacing Using LabView

VME Data Acquisition System, ADC Read

OVERVIEW GOALS KEY TERMS

LabVIEW Basics I: Introduction Course

LABVIEW LAB SKILLS ACTIVITY 1 PROGRAMING ENVIRONMENT

Introduction to National Instruments LabVIEW and Data Acquisition (DAQ)

Basic Data Acquisition with LabVIEW

PCI-express data acquisition card DAQ0504M User Guide

Ch En 475: Introduction to Instrumentation and Signal Processing with Labview

Labview for Everyone (National Instruments Virtual Instrumentation Series) Jeffrey Travis

Engineering Innovation Center LabVIEW Basics

ME 224: EXPERIMENTAL ENGINEERING. Lecture 2

Today. 4/5/11 Physics 262 Lecture 10 Questions about Exams Homework. Lab: Continue project. Lecture. Review your exams and review practice exam again.

Dept. of Electrical, Computer and Biomedical Engineering. Data Acquisition Systems and the NI LabVIEW environment

LabVIEW Express VI Development Toolkit User Guide

LabVIEW programming I

Lab 2: Introduction to LabVIEW 8.5

Lab 4 - Data Acquisition

University of Pennsylvania. Department of Electrical and Systems Engineering. ESE Undergraduate Laboratory. Introduction to LabView

Getting Started with LabVIEW Virtual Instruments

The data acquisition components, and their relationship to each other, are shown below.

Introduction to Electronics Workbench

Vernier SensorDAQ User s Manual

ENGR 1000, Introduction to Engineering Design

LabVIEW programming I

NAME EET 2259 Lab 3 The Boolean Data Type

EE 100 DMM and DC Power Supply LabVIEW Experiment Guide

NI LabView READ THIS DOCUMENT CAREFULLY AND FOLLOW THE INSTRIUCTIONS IN THE EXERCISES

Introduction to LabVIEW

PHYC 500: Introduction to LabView. Exercise 16 (v 1.2) Controlling hardware with DAQ device. M.P. Hasselbeck, University of New Mexico

Virtual Instrumentation With LabVIEW

Introduction to LabVIEW Exercise-1

TUTORIAL. Ve r s i on 1. 0

Lesson 1 Introduction to LabVIEW. TOPICS LabVIEW Environment Front Panel Block Diagram Dataflow Programming LabVIEW Help and Manuals Debugging a VI

ECE 202 LAB 1 INTRODUCTION TO LABVIEW

The LabScribe Tutorial

PHYC 500: Introduction to LabView. Exercise 1 (v 1.3) M.P. Hasselbeck, University of New Mexico

Dept. of Electrical, Computer and Biomedical Engineering. Instrumentation for the data acquisition laboratory

BE/EE189 Design and Construction of Biodevices Lecture 5. BE/EE189 Design and Construction of Biodevices - Caltech

Hands-on Lab 1: LabVIEW NI-DAQ Basics 1

Advanced NI-DAQmx Programming Techniques with LabVIEW

Lab 1: Getting familiar with LabVIEW: Part I

LabVIEW Experiment 1 Light Sensor Calibration Using Arduino Data Acquisition (Arduino DAQ)

Determination of Drag Coefficient

ECE 463 Lab 1: Introduction to LabVIEW

PHYS 5061 Lab 6 Programmable Instruments

Install the Software and Hardware

Learn the three palettes. Learn how data is passed in LabVIEW. Create a subvi using two different methods.

eace PLC Velocio s Embedded Ace (eace) PLC

FRC LabVIEW Sub vi Example

Virtual Instrumentation With LabVIEW

Exercise 5: Basic LabVIEW Programming

CLAD Exam Preparation Guide using LabVIEW NXG

LabVIEW. Table of Contents. Lesson 1. Pre-reqs/Technical Skills Basic computer use

TECH 3821 Lab #2 Relay Driver with Computer Control

Introduction to Computer Engineering (E114)

the NXT-G programming environment

DSP First Lab 02: Introduction to Complex Exponentials

PSpice Tutorial. Physics 160 Spring 2006

A variety of ECONseries modules provide economical yet flexible solutions. Waveform Generation

Above Threshold Warning of Temperature Data

Part 1. Summary of For Loops and While Loops

Using the Zoo Workstations

WELCOME TO LabVIEW 1

OpenStax-CNX module: m Thermometer VI * National Instruments

CSCI 1100L: Topics in Computing Lab Lab 1: Introduction to the Lab! Part I

Hardware: Acquiring Data and Communicating with Instruments

Learn LabVIEW 2010 / 2011 Fast

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

Computer Basics: Step-by-Step Guide (Session 2)

Faculty of Computing, Engineering and Technology. Real Time Systems 1 CE LabVIEW David D. Hodgkiss & Staffordshire University 1

Data Acquisition in LabVIEW

BE/EE189 Design and Construction of Biodevices Lecture 2. BE/EE189 Design and Construction of Biodevices - Caltech

Teaching Computer-Based Data Acquisition and Analysis Research Skills Using LabVIEW

User Interfaces in LabVIEW

Labview Lab 2. Vern Lindberg. April 16, 2012

NI mydaq HANS-PETTER HALVORSEN, Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Labview. Masood Ejaz

Help Volume Agilent Technologies. All rights reserved. Agilent E2485A Memory Expansion Interface

Transcription:

PHY 351/651 LABORATORY 1 Introduction to LabVIEW Introduction Generally speaking, modern data acquisition systems include four basic stages 1 : o o A sensor (or transducer) circuit that transforms a physical quantity (e.g. temperature, charge, pressure, mechanical strain, light intensity, etc.) into an electronic signal (either a voltage or a current). Front-end electronic circuitry that amplifies and shapes the analog signal from the sensor to make it detectable for digitization in the next stage of circuitry, the back-end circuitry. o Back-end electronic circuitry also referred to as data acquisition hardware or DAQ card - that further processes the analog signal and then converts it into a digital signal that can be processed and stored by a computer. o A computer that is programmed to retrieve, store and in many cases analyze the digitized data so that it can be easily retrieved, interpreted, and presented by the scientist performing the measurement. Over the course of the semester, you will learn about all four of these elements of data acquisition. However, you will start the semester by becoming familiar with the hardware and software you will use in this laboratory for back-end circuitry and for programming of the laboratory computers for processing and storage of data (i.e. steps 3 and 4 above). Specifically today, you will begin learning a widely-used programming environment known as LabVIEW (Laboratory Virtual Instrument Engineering Workbench), which will ultimately enable you to utilize a computer in a powerful manner for monitoring, controlling and conducting scientific experiments. Today s learning objectives are as follows: Laboratory 1 Learning Objectives: o o Learn to use LabVIEW to interface, in a very basic manner, with the back-end hardware connected to your PC 2. For today you will simply learn how one would inspect and configure installed hardware through something known as the Measurement Automation Explorer (MAX). Learn to use LabVIEW to construct and operate basic virtual instruments (VIs). In LabVIEW, VIs are programs that serve many functions: they might be used to facilitate communication with other instruments; they might be used to imitate physical instruments by generating a signal from the computer 1 See the following link for a more detailed general overview of modern computer-based data acquisition systems: http://www.ni.com/data-acquisition/what-is/. 2 You should keep in mind the example I showed at the beginning of class of DAQ hardware that is connected to the computer through installation in PCI expansion slots in the motherboard. In some situations, this arrangement may be preferable due to higher throughput of data. Page 1

or conditioning signals received by the computer; or they might serve as elements ( nodes or sub-vis ) for processing information in other VIs. In today s lab you will briefly explore a professionally made VI that simulates a digital oscilloscope. Afterwards you will develop some rudimentary VIs for performing various calculations, generating random numbers and generating a sine wave. Introduction to the LabVIEW Environment LabVIEW provides a programming environment with standard interfaces between a computer and a variety of back-end electronics and front-end instruments. As well, it can be used for simulation and general programming. As you will learn over the semester, one of the major advantages (and also a potential pitfall) of LabVIEW is that is based upon a very intuitive graphical programming language (a form of data flow programming known as G ) that does not require extensive programming experience to execute many operations that are vital for the collection and processing of data. As a result, even a novice user can utilize LabVIEW to design measurement and automation systems that employ low-cost, flexible PC technology. LabVIEW's graphical programming language provides easy means for scientists and engineers of diverse background to quickly design and implement complex test and measurement and automation applications. The first cycle of laboratory sessions will familiarize you with this programming tool and the way it is used in most laboratories. Activity 1 A First Peak at Measurement Automation Explorer (MAX) Goal: In this activity, you will utilize LabVIEW via MAX to familiarize yourself with the DAQ card that will be connected to your PC. Note: The DAQ that we will use this semester is the NI USB-6003, a commercial board that was developed by National Instruments (Figure 1, next page). This board includes screw-terminal interconnects for multi-channel analog I/O (that s short for Input/Output), digital I/O, counters, timers, and ports for triggering. In particular, you can digitize up to 4 differential analog inputs or 8 single-ended inputs (all with 16 bit resolution); and you can generate algorithms that use 8 lines of digital I/O. Also, the 6003 provides 2 channels of analog output (14 bit resolution). If the terminology I m using here is unfamiliar, don t worry; by the end of the semester it should be second nature. In fact, a good way to begin learning is to peruse the Page 2

Figure 1: The USB-6003 Multifunction DAQ. A USB port allows connection to a computer. Screw terminals provide connections to external circuitry. specification sheets that I have handed out for these devices, and which are also posted on blackboard. I encourage you to have a quick look at these sheets now and then a more thorough reading on your own before the next lab (actually some of the questions at the end of the lab require that you read the specs). Steps: 1. After you re done browsing the spec sheets for the 6003, it s time to see how one would access it using LabVIEW. Power up the computer in front of you, and then click the LabVIEW icon from the desktop. A LabVIEW pop-up screen should appear. 2. There are several options at this point. Create Project will allow you to create a new virtual instrument (we will explore this later on in the class). Open Existing allows you to edit or run a VI that has already been created. You should also notice the Tools menu in tool bar at the top of the screen. This menu provides access to many different options for augmenting and controlling the LabVIEW environment. What you should do is click on Measurement & Automation Explorer (aka MAX). **Throughout the semester (or even beyond this semester) this will enable you to explore and configure any data acquisition hardware that has been installed in or connected with the PC. ** 3. On the left-hand side of the screen, you will see a list of folders. Click on the one labeled Devices and Interfaces. This is where you see a list of all hardware components recognized by LabVIEW and installed in your system; you should see the USB-6003 here Page 3

- make sure it shows up. If you click on USB-6003 in the list, you get a list of options, including as self-test feature. 4. To access the channel of the USB-6003 you will have to configure virtual channels or tasks. A virtual channel will return data that has been properly scaled and has the proper units (e.g. Volts or C). However, with virtual channels, it is up to you to explicitly program the other details of timing and triggering in setting up the application. A task encapsulates all of the information in the virtual channel plus the timing and triggering information. You can set up a task in MAX. Right-click Data Neighborhood and select Create New. Follow the instructions to set up e.g. a voltage read-back channel. Use the USB-6003 spec sheet (linked on class home page) to figure out which ports to connect to the function generator. Set the function generator up to produce a 1 Hz sine wave. You can verify that your task is configured properly by running it you should see the 1 Hz sine wave signal. 5. Now let s get an idea of how a virtual channel or tasks can serve as a well-controlled conduit through which data can be passed into your computer. Minimize MAX and find the LabVIEW pop-up window. Click on Open Existing. Find the folder C:\Program Files (x86)\national Instruments\LabVIEW 2014\vi.lib and open up the VI 2 Channel Oscilloscope.vi 6. Two new windows should appear looking similar to the windows in Figure 2 and Figure 3 on the following pages. You have now opened the oscilloscope VI. 7. The two windows that have appeared are the VI s front panel (Figure 2) and block diagram (Figure 3). The front panel and block diagram are two of the three main components in any VI (the third component is the connector panel, which is indicated in figure 2, and will be explored later on). As you can see, the front panel is a graphical user interface (GUI) that quite closely resembles the front panel of any laboratory instrumentation (like an oscilloscope) that you may have used before. This screen is the one that would be used to set up and execute a desired measurement. There are controls, which allow you to supply input parameters to the VI (such as voltage scale and time-base). There are indicators which specify the parameter values that have been selected. And there is a graph that displays data that the VI has recorded versus time where this data comes from can be controlled by setting the controls Channel A and Channel B 3 to the desired virtual channel that you would have just created in MAX if we had our DAQ boards. **In short, what you are looking at is a virtual oscilloscope, similar in function to the physical oscilloscope sitting next to the PC on your table. For the physical 3 Note: The control for Channel B has been hidden for some reason in this program. Ask the instructor to show you how to make it visible. Page 4

Tools Palette VI Icon Front Panel Controls Controls Palette Figure 2: Front panel window for the LabVIEW VI 2 channel oscilloscope Page 5

Data Flow Programming Code Functions Palette Tools Palette Figure 3: Block diagram window for the LabVIEW VI 2 channel oscilloscope. oscilloscope, signals (data) are input through the front panel connectors. For the virtual oscilloscope, signals (data) are input through the hardware channels on your DAQ, processed through the virtual channels you ve set up in MAX, and then displayed on your computer screen. In a few weeks you will know how to create VIs with the same functionality. For now, try to use this virtual oscilloscope to display the 1Hz sine wave you set up. ** 8. You will also notice that there are a couple of pop-up windows on the front panel. The smaller one is known as the tool palette; when building your front panel GUI, this palette provides tools that allow you to click, drag, modify, etc the various controls and other elements you place on the front panel. The larger pop-up window is known as the Page 6

control palette; it harbors various style and function controls, indicators, graphs and other elements that you might want to incorporate in your virtual instrument. 9. If you now locate the block-diagram panel (you can do so by pressing ctrl-e), you will see the graphical programming or source code for the VI. The elements you see on the screen are nodes, representing various operations and inputs/outputs. Data flows in the program from left to right between these nodes via various types of wiring (here each type of wiring represents a conduit for a specific format of data). Various function nodes for the source code can be added via the functions palette. If you click the light bulb icon in the tool bar at the top of the block diagram, and then click run (the white arrow in the tool bar, equivalently ctrl-r), you will be able to actually watch the data flow while the VI is being executed; and the parallel nature of LabVIEW programming will be evident. For your lab report: o Describe the elements of a data acquisition system. If possible, to help illustrate the elements, provide an example from any experiences you ve had in research or through second-hand knowledge of research (i.e. from reading on the web, talking to friends, etc). o Also provide a sketch of the elements of the data acquisition system you just implemented in this first activity using the oscilloscope. Activity II Build your first VI Goal: Generate a VI that calculates the sum of the squares of two numbers and displays the result. Steps: 1. Create a folder on the desktop with your name. 2. Open LabVIEW and select Create Project. 3. On the front panel, using the control palette, add 2 digital controls (ultimately to enter inputs for your calculations) and one digital indicator (to display the result of your calculation). Note that there are multiple style options for the controls (Modern, Silver, Classic, etc). As far as I m aware, the functionality does not change between these different styles. 4. Use save as in the file menu to save this vi in the folder you just created. 5. Open the block diagram window and, using the functions palette, under the programming menu, numeric palette, add the necessary numeric functions to calculate the sum of the squares of the two input numbers. In order to perform the full calculation you will need to wire the numeric functions (nodes) together and to the input and outputs. You can do this using the tools palette: click on the spool of wire icon; this will change the cursor to a spool; you can then click on and connect the two elements that you desire. If you make a mistake in the wiring, you can delete the wires by using the cursor to select a wire and then clicking delete. You can also remove broken wires using the ctrl-b function. 6. Once you have finished building your program, go back to the front panel, input into the two controls the two numbers of which you want to calculate the sum of the squares, and then click run. Check to make sure that the answer given in the digital indicator makes Page 7

sense. 7. After you are satisfied with the operation of your program, spend some time sprucing up the appearance of the front panel using decorations which can be found on the controls palette. When you re done with decorating, run the VI again to make sure you haven t screwed anything up. 8. Then under the file menu select VI properties. In the category documentation, enter a description of this VI. Under VI properties you should also explore memory usage to see how much memory the program utilizes, and check the location where the file is stored. 9. Save the completed VI in your folder. For your lab report: Include a picture of the front panel and a picture of the block diagram for this VI. (You can save a picture by using print screen). Activity III Build your second VI Goal: Build a VI that compares an integer number to the number 5 and then either produces (1) a green LED light if the number is greater than 5 (plus the word over ) or (2) a red LED light if (plus the word over ) if the number is less than or equal to 5. Note: With this activity I am not giving you step-by-step instructions for a reason: I want you to think about what you have learned from the previous program and now apply it to this new situation. Of course, if you get unduly stuck, ask for help. Also, be sure to save your work. For your lab report: Include a picture of the front panel and a picture of the block diagram for this VI. Activity IV Creating your first sub-vi Goal: Transform the VI from Activity III into a sub-vi that can be used in more complex programs. Note: If you have any experience with programming, you are well aware that good programs are modular: you design your building blocks, each to perform a specific task, and then you link the blocks together as needed in the more complex program. If you go back to the oscilloscope VI that you explored in Activity I, you will see that there are many icons on the block diagram that represent sub-vis but which can also be operated as stand-alone VIs. In order to transform a VI into a sub-vi that can be used in other programs you have to learn to manipulate the VI s connector panel icon (top right corner of either window in the VI; see figure 2). You can edit it starting from the VI property window (under file menu) or by double-clicking on the icon itself. Steps: 1. To start, you will change the design of the icon for the VI from Activity III. Double-click on the icon in the upper-right corner. Then use the editing tools to change the design on the icon to an image that suits you. (More practically, the image should reflect the function of the VI.) Page 8

2. Next, you need to configure the VI for connections to the outside world. To do this, right-click on the terminal pane next to the icon, and select patterns. 3. Choose the terminal layout that you feel best suits this example (i.e. how many input? How many outputs?). 4. Click on a terminal; the wiring tool will appear. Connect it to the desired control or indicator on the front panel. A moving dotted line will appear when you successfully make the connection. 5. Click on an open area of the front panel. 6. Then repeats as necessary for the other terminals. Save this VI with another name and then construct a new VI that performs the same function by utilizing this VI as a sub-vi. Document the new VI, and save it in your folder. As always, ask for help if you get stuck. For your lab report: Include a picture of the front panel and of the block diagram of the two VIs from this activity. Activity V Build a VI that generates a sinusoid waveform Goal: Follow the example in chapter 1 of the hand out from John Essick s book Hands-On Introduction to LabVIEW to build a VI that generates a sinusoid waveform. Note: You should bear in mind that Essick s book was written for a much later version of LabVIEW than we have here in the class. Therefore, do not be surprised if some of the features he refers to are not present in our verion or are located in different menus (folders, subpalettes,etc) in our version. To prevent undue confusion, I have included at the end of this handout a list of the instances in the sine wave example where Essick s instructions differ from our version; and I have provided the appropriate instructions. Final Questions to be answered in your lab report Provide answers to the following questions in your lab report. Do this at home. (You may consult any source you find helpful to answer these questions.) 1. What is the difference between differential, referenced single-ended, and non-referenced single-ended wiring configurations in standard NI DAQ boards? 2. In the context of LabVIEW, what is a virtual channel? 3. In the context of LabVIEW, what is a virtual instrument? 4. What is the difference between double-precision floating point data format and singleprecision floating point format? What is the difference between unsigned four-byte integer format and signed four-byte integer format? What is Boolean data format? 5. What is a waveform graph in LabVIEW? 6. What is a while loop? Page 9