lab equipment: ni mydaq - home.hit.nohome.hit.no/~hansha/documents/lab/lab equipment/mydaq/ni...

20
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 NI myDAQ HANS-PETTER HALVORSEN, 2012.01.20

Upload: vonhu

Post on 30-Mar-2018

224 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

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

NI myDAQ HANS-PETTER HALVORSEN, 2012.01.20

Page 2: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

ii

Table of Contents

Table of Contents .....................................................................................................................................ii

1 Introduction to myDAQ .................................................................................................................. 1

2 System Description ......................................................................................................................... 3

3 Installation and Configuration ........................................................................................................ 4

4 Using myDAQ as a Multimeter ....................................................................................................... 5

5 Using myDAQ as a Scope ................................................................................................................ 7

6 Using myDAQ as a Function Generator .......................................................................................... 8

7 Using myDAQ in LabVIEW ............................................................................................................... 9

7.1 NI-DAQmx ................................................................................................................................ 9

7.1.1 DAQ Assistant .................................................................................................................. 9

7.1.2 Using DAQmx functions ................................................................................................. 16

7.2 NI-ELVISmx ............................................................................................................................ 17

Page 3: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

1

1 Introduction to myDAQ

NI myDAQ is a simple and intuitive DAQ device from National Instruments. NI myDAQ have Analog

Inputs (AI), Analog Outputs (AO), Digital Inputs (DI) and Digital Outputs (DO).

In addition to traditional I/O, the myDAQ have a built-in Digital Multimeter. The myDAQ can also be

used as a Power Supply. Using the built-in software the myDAQ can also be used as an Oscilloscope

and Function Generator.

When you plug in the device in the USB connection on your PC, the following will pop-up

automatically (NI ELVISmx Instrument Launcher):

Note! You need to install the NI ELVISmx driver software first

If not, you find it in the National Instruments folder:

Page 4: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

2 Introduction to myDAQ

Lab Equipment: NI myDAQ

If you click on the DMM button, the built-in Digital Multimeter will appear:

If you want to use the myDAQ inside LabVIEW for Data Acquisition, you either use the traditional

NI-DAQmx features or you may use NI-ELVISmx features. Both will be shown in this Tutorial.

Page 5: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

3

2 System Description

Below we see an overview of the NI myDAQ device:

Specifications:

Two Differential Analog Input and Analog Output Channels (200 ks/s, 16 bit, +/- 10 Volts)

Eight Digital Input and Digital Output Lines (3.3 Volt TTL-Compatible)

+5 , +15, and -15 Volt Power Supply Outputs (up to 500m Watts of Power)

60 Volt Digital Multimeter (DMM) for Measuring Voltage, Current, and Resistance

The following are included in the package:

Page 6: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

4

3 Installation and

Configuration

You need to install the NI-ELVISmx software that comes with the device. The NI-ELVISmx software

installs the DAQmx driver software as well as the Measurement and Automation Explorer.

You use MAX (Measurement and Automation Explorer) for configuration.

Perform a “Self-Test” to make sure everything works as expected:

Page 7: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

5

4 Using myDAQ as a

Multimeter

When you plug in the device in the USB connection on your PC, the following will pop-up

automatically (NI ELVISmx Instrument Launcher):

If you click on the DMM button, the built-in Digital Multimeter will appear:

Page 8: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

6 Using myDAQ as a Multimeter

Lab Equipment: NI myDAQ

Make sure to connect the applied digital multimeter probes:

Page 9: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

7

5 Using myDAQ as a Scope

When you plug in the device in the USB connection on your PC, the following will pop-up

automatically (NI ELVISmx Instrument Launcher):

If you click on the Scope button, the built-in Scope will appear:

Page 10: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

8

6 Using myDAQ as a

Function Generator

When you plug in the device in the USB connection on your PC, the following will pop-up

automatically (NI ELVISmx Instrument Launcher):

If you click on the FGEN button, the built-in Function Generator will appear:

Page 11: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

9

7 Using myDAQ in LabVIEW

If you want to use the myDAQ inside LabVIEW for Data Acquisition, you either use the traditional

NI-DAQmx features or you may use NI-ELVISmx features. Both will be explained in detail below.

7.1 NI-DAQmx

In order to use the myDAQ device in LabVIEW you need to use the DAQmx functions.

Below we see the DAQmx palette in LabVIEW (Measurement I/O → NI-DAQmx)

7.1.1 DAQ Assistant

We will create a very simple example with 2 VIs, one VI for writing (Analog Out) and one for reading

(Analog In).

Analog Out:

In this simple example we will use AO0 (Analog Out, Channel 0).

We use the DAQ Assistant (DAQ Assist) which we find in the DAQmx palette.

Page 12: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

10 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

When dragging this VI to the Block Diagram, the following Wizard appears:

We shall write data, so we need to select “Generate Signals”.

Since we are going to write data to AO0, we select “Analog Output” and “Voltage”:

Page 13: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

11 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

Next we select AO0:

Finally we set properties for Min and Max values, Timing Settings, etc.:

In our case we set “1 Sample (On Demand)”.

Page 14: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

12 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

Next, we need to finish our LabVIEW application as follows:

In addition to the DAQ Assistant we a While Loop, a “Wait (ms)” function.

On the Front Panel we need Numeric Control and a Stop Button:

Analog In:

In this simple example we will use AI0 (Analog In, Channel 0).

We use the DAQ Assistant (DAQ Assist) which we find in the DAQmx palette.

Page 15: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

13 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

When dragging this VI to the Block Diagram, the following Wizard appears:

We shall read data, so we need to select “Acquire Signals”.

Since we are going to read data from AI0, we select “Analog Input” and “Voltage”:

Page 16: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

14 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

Next we select AI0:

Finally we set properties for Min and Max values, Timing Settings, etc.:

In our case we set “1 Sample (On Demand)”.

Page 17: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

15 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

Next, we need to finish our LabVIEW application as follows:

In addition to the DAQ Assistant we a While Loop, a “Wait (ms)” function.

On the Front Panel we need Numeric Indicator and a Stop Button:

In order to test the applications, we can wire AO0 and AI0 together (a so-called Loopback text). If we

write 3V in the “Write Analog Out.vi”, we should be able to read 3V in the “Read Analog In.vi”.

Page 18: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

16 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

7.1.2 Using DAQmx functions

Another approach is to put the DAQ Assistant outside the loop for better performance.

Analog Out:

In this example we have used the DAQmx functions “DAQmx Start Task.vi”, “DAQmx Write.vi” and

“DAQ Clear Task.vi” from the DAQmx palette.

Analog In:

In this example we have used the DAQmx functions “DAQmx Start Task.vi”, “DAQmx Read.vi” and

“DAQ Clear Task.vi” from the DAQmx palette.

The applications will work exactly the same as in the previous example, but the performance will be

slightly better, especially for larger applications.

Page 19: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

17 Using myDAQ in LabVIEW

Lab Equipment: NI myDAQ

7.2 NI-ELVISmx

Below we see the NI ELVISmx palette in LabVIEW (Measurement I/O → NI ELVISmx)

The NI ELVISmx palette consists of different Express Vis.

Digital Multimeter:

Oscilloscope:

Function Generator:

Page 20: Lab Equipment: NI myDAQ - home.hit.nohome.hit.no/~hansha/documents/lab/Lab Equipment/myDAQ/NI myDAQ.pdfNI myDAQ is a simple and intuitive DAQ device from ... Eight Digital Input and

Telemark University College

Faculty of Technology

Kjølnes Ring 56

N-3918 Porsgrunn, Norway

www.hit.no

Hans-Petter Halvorsen, M.Sc.

Telemark University College

Faculty of Technology

Department of Electrical Engineering, Information Technology and Cybernetics

E-mail: [email protected]

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