Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics Datalogging in LabVIEW HANS-PETTER HALVORSEN, 2011.01.04 Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
PREFACE In this lab you will learn basic Data Acquisition (DAQ) and how to use a DAQ unit in LabVIEW. We will use the USB-6008 DAQ device from National Instruments. NI USB-6008 is a simple and low-cost USV based multifunction I/O device from National Instruments. The device is well suited for training and education purpose. The purpose of data acquisition is to measure an electrical or physical phenomenon such as voltage, current, temperature, pressure, or sound. PC-based data acquisition uses a combination of hardware, software, and a computer to take measurements. The principle of Data Acquisition: USB-6008 DAQ device from National Instruments: ii
TABLE OF CONTENTS Preface... ii Table of Contents... iii 1 Introduction to Data Acquisition...4 2 Datalogging...8 3 Additional Tasks...15 iii
1 INTRODUCTION TO DATA ACQUISITION In this task we will learn basic Data Acquisition in LabVIEW. We will use the USB-6008 DAQ device. Background information for this task is described in detailed in the Tutorial Data Acquisition in LabVIEW. The Tutorial consists of pdf documents, videos, example code, additional resources and links. http://home.hit.no/~hansha/?tutorial=daq The purpose of data acquisition is to measure an electrical or physical phenomenon such as voltage, current, temperature, pressure, or sound. PC-based data acquisition uses a combination of modular hardware, application software, and a computer to take measurements. While each data acquisition system is defined by its application requirements, every system shares a common goal of acquiring, analyzing, and presenting information. Data acquisition systems incorporate signals, sensors, actuators, signal conditioning, data acquisition devices, and application software. So summing up, Data Acquisition is the process of: Acquiring signals from real-world phenomena Digitizing the signals Analyzing, presenting and saving the data 4
5 Introduction to Data Acquisition The DAQ system has the following parts involved, see Figure: The parts are: Physical input/output signals DAQ device/hardware Driver software Your software application (Application software) The NI-DAQmx Driver software is the layer of software for easily communicating with the hardware. It forms the middle layer between the application software and the hardware. Driver software also prevents a programmer from having to do register-level programming or complicated commands in order to access the hardware functions. The DAQmx palette in LabVIEW: The DAQ Assistant, included with NI-DAQmx, is a graphical, interactive guide for configuring, testing, and acquiring measurement data. With a single click, you can even generate code based on your configuration, making it easier and faster to develop complex operations. Because DAQ Assistant is completely menu-driven,
6 Introduction to Data Acquisition you will make fewer programming errors and drastically decrease the time from setting up your DAQ system to taking your first measurement. NI USB-6008 is a simple and low-cost multifunction I/O device from National Instruments. The device has the following specifications: 8 analog inputs (12-bit, 10 ks/s) 2 analog outputs (12-bit, 150 S/s) 12 digital I/O USB connection, No extra power-supply neeeded Compatible with LabVIEW, LabWindows/CVI, and Measurement Studio for Visual Studio.NET NI-DAQmx driver software The NI USB-6008 is well suited for education purposes due to its small size and easy USB connection. Measurement & Automation Explorer (MAX) provides access to your National Instruments devices and systems. With MAX, you can: Configure your National Instruments hardware and software Create and edit channels, tasks, interfaces, scales, and virtual instruments Execute system diagnostics View devices and instruments connected to your system Update your National Instruments software In addition to the standard tools, MAX can expose item-specific tools you can use to configure, diagnose, or test your system, depending on which NI products you install. As you navigate through MAX, the contents of the application menu and toolbar change to reflect these new tools.
7 Introduction to Data Acquisition
2 DATALOGGING In this task we will connect our DAQ device to a real process (small-scale model). Below we see the Lab Equipment available for this assignment: Level Tank Air Heater In this Lab we can select one of these models. Which one you use is not relevant for the purpose of this lab work. Documents of how to use the Level Tank/Air Heater and the USB-6008 DAQ device is available from http://home.hit.no/~hansha. Level Tank: http://home.hit.no/~hansha/?equipment=leveltank Air Heater: http://home.hit.no/~hansha/?equipment=airheater USB-6008: http://home.hit.no/~hansha/?equipment=usb6008 Task 1: Test DAQ Device on Real Process Select one of the processes above and connect you DAQ device to the system. Log data (Temperature for the Air Heater system or Level for the Water Tank) for different input signals (u). Show the results in a Chart. You may want to use the Waveform Chart located in the Graph palette: 8
9 Datalogging Here is a LabVIEW example: Scaling: Make sure to scale the output signal from the system (Voltage signal) to Temperature (Air Heater) or Level (Water Tank). Air Heater output: 1-5V 20-50 o C. Water Tank output: 0-5V 0-20cm. The following linear relationship applies:
10 Datalogging You have to find a (slope) and b (intercept). The following formulas may be used: This gives: where It is good practice to implement the scaling using a SubVI. [End of Task] Task 2: Manual Control Try to act like a controller: Let s say you want the setpoint to be 15cm (Level Tank)/35 degrees C (Air Heater) and then try to manually adjust the control signal (u) so the Temperature stays on the setpoint. You need to extend the program from a previous task so that the control signal u is sent to the DAQ unit. Use the DAQmx Write.vi :
11 Datalogging [End of Task] Task 3: Write to Measurement File Extend your program so the logged data can be saved to a Measurement File. You can use the Write to Measurement File function on the File I/O palette in LabVIEW for writing data to text files (use the LVM data file format, not the TDMS file format which give binary files). Recommended settings for the Write To Measurement File :
12 Datalogging Example of LabVIEW Program: Open the *.lvm file in, e.g., Notepad in order to see the results. [End of Task]
13 Datalogging Task 4: Read from Measurement File: Create another program that open the measurement file and shows the data in an array and a Graph. Use the Read From Measurement File in LabVIEW. Recommended settings for the Read From Measurement File : Example of LabVIEW program:
14 Datalogging You should also open the file in Excel and plot the data in Excel. [End of Task] Task 5: Import Data to Excel In this task we will open the measurement file created in a previous task in MS Excel. Open the measurement file in Excel Calculate the average (mean) of the logged data (use the built-in mean function in Excel) Create a plot of the logged data [End of Task]
3 ADDITIONAL TASKS Task 6: Datalogging and Virtual Instruments Create a Virtual Instrument with the following components: 1. Toolbar 2. Owned Label 3. Numeric Control 4. Free Label 5. Numeric Control Terminal 6. Knob Terminal 7. Numeric Constant 8. Multiply Function 9. Icon 10. Knob Control 11. Plot Legend 12. XY Graph 13. Wire Data Path 14. XY Graph Terminal 15. Bundle Function 16. SubVI 17. For Loop Structure Below we see the front panel and the block diagram for the virtual instrument. 15
16 Additional Tasks The SubVI (number 16) shall read the temperature from the Air Heater using the USB-6008 DAQ (Data Acquisition) device.
17 Additional Tasks
Telemark University College Faculty of Technology Kjølnes Ring 56 N-3914 Porsgrunn, Norway www.hit.no Hans-Petter Halvorsen, M.Sc. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics Phone: +47 3557 5158 E-mail: hans.p.halvorsen@hit.no Blog: http://home.hit.no/~hansha/ Room: B-237a