Using DAQ Devices in LabVIEW

16
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics 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 Using DAQ devices in LabVIEW HANS-PETTER HALVORSEN, 2011.01.04

Transcript of Using DAQ Devices in LabVIEW

Page 1: Using DAQ Devices in LabVIEW

Telemark University College

Department of Electrical Engineering, Information Technology and Cybernetics

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

Using DAQ devices in LabVIEW

HANS-PETTER HALVORSEN, 2011.01.04

Page 2: Using DAQ Devices in LabVIEW

ii

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:

Page 3: Using DAQ Devices in LabVIEW

iii

TABLE OF CONTENTS

Preface ..................................................................................................................................................................... ii

Table of Contents .................................................................................................................................................... iii

1 Introduction to Data Acquisition ....................................................................................................................4

2 Measurement and Automation Explorer (MAX) ............................................................................................8

3 Using the DAQ Assistant ...............................................................................................................................10

Page 4: Using DAQ Devices in LabVIEW

4

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 a pdf document, videos, example code, additional resources and web 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

Page 5: Using DAQ Devices in LabVIEW

5 Introduction to Data Acquisition

Lab Work: Using DAQ devices in LabVIEW

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)

In LabVIEW, 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.

Below we see 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,

Page 6: Using DAQ Devices in LabVIEW

6 Introduction to Data Acquisition

Lab Work: Using DAQ devices in LabVIEW

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.

Page 7: Using DAQ Devices in LabVIEW

7 Introduction to Data Acquisition

Lab Work: Using DAQ devices in LabVIEW

Page 8: Using DAQ Devices in LabVIEW

8

2 MEASUREMENT AND AUTOMATION EXPLORER (MAX)

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

Task 1: MAX

Connect you USB-6008 Device and open the Measurement and Automation Explorer (MAX). See if you can

find you DAQ device in MAX and make sure it works properly. Run a “Self Test” and open the “Test Panels” in

order to test your device.

Perform a so-called Loopback test.

Page 9: Using DAQ Devices in LabVIEW

9 Measurement and Automation Explorer (MAX)

Lab Work: Using DAQ devices in LabVIEW

Use a multi-meter to check if the voltage levels on the output and input channels are correct according to your

settings.

[End of Task]

Page 10: Using DAQ Devices in LabVIEW

10

3 USING THE DAQ ASSISTANT

Note! Read the “USB-6008 DAQ device” Lab Equipment document before you start!

The document and additional information is available from: http://home.hit.no/~hansha/?equipment=usb6008

Connect your USB-6008 DAQ device to your computer and make sure it works. Use the Measurement and

Automation Explorer (MAX) to configure and test your device. Use also a Volt meter to check that the voltage is

correct.

Measurement and Automation Explorer (MAX):

The Data Acquisition palette in LabVIEW:

DAQ Assistant:

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.

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.

Page 11: Using DAQ Devices in LabVIEW

11 Using the DAQ Assistant

Lab Work: Using DAQ devices in LabVIEW

Task 2: Analog Output

Create a program in LabVIEW that write analog values from the USB-6008 DAQ device. Use the DAQ Assistant.

The program should include a While loop that continuously write values from the USB-6008 DAQ device.

Example:

The DAQ Assistant Properties should look something like this:

Page 12: Using DAQ Devices in LabVIEW

12 Using the DAQ Assistant

Lab Work: Using DAQ devices in LabVIEW

Use an ordinary “Numeric Control” on the Front Panel in order to write data between 0 and 5 [V] to the DAQ

device.

Write different values between 0 and 5 [V] and use a multi-meter in order to check if the program works as

expected.

[End of Task]

Task 3: Analog Input

Create a program in LabVIEW that read analog values from the USB-6008 DAQ device. Use the DAQ Assistant.

The program should include a While loop that continuously reads values from the USB-6008 DAQ device.

Example:

The DAQ Assistant Properties should look something like this:

Page 13: Using DAQ Devices in LabVIEW

13 Using the DAQ Assistant

Lab Work: Using DAQ devices in LabVIEW

Run the “Analog Output.vi” and the “Analog Input.vi” in parallel in order to check that the program works as

expected. See the example below.

[End of Task]

Task 4: Combined Analog In and Analog Out

Create a new program where you connect the Analog Input and Analog Output programs together in one

program.

Specifications for the application:

Put the Analog Input and Analog Output code into different SubVIs.

Page 14: Using DAQ Devices in LabVIEW

14 Using the DAQ Assistant

Lab Work: Using DAQ devices in LabVIEW

Do some calculations on the input signal and send the calculated result to the analog output. Put the

calculation code into a SubVI.

Plot the different values on the screen.

Use the Project Explorer in LabVIEW for your application.

Create an Executable File (.exe) of your Application.

In order to use the Project Explorer, you will have to create an “Empty Project”:

Below we see an example of the Project Explorer:

Below we see how we can use the Project Explorer to create an .exe (executable) file:

Page 15: Using DAQ Devices in LabVIEW

15 Using the DAQ Assistant

Lab Work: Using DAQ devices in LabVIEW

[End of Task]

Page 16: Using DAQ Devices in LabVIEW

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: [email protected]

Blog: http://home.hit.no/~hansha/

Room: B-237a