SessionVI_Notecard

advertisement

Session VI Notecard

– DAQmx Intro

PRELIMS

I.

S IGN IN ON A TTENDANCE S HEET

II.

C HECK OUT DAQ S TO E ACH S TUDENT

III.

B IG F IXES

[LVTraining_Aut10]

REVIEW

IV.

D ISCUSS C URRICULUM P ROGRESSION

SESSION

I.

S ESSION O VERVIEW

II.

DAQ S YSTEMS – L AYOUT

Before diving into the use of a DAQ, take a moment to first consider both its role and implementation into a T&M system. T&M systems interface sub-systems/other systems to achieve their tasks. Interfaces include:

Communication Links o Analog (RF, etc.) o

Digital (Serial/Parallel)

Measurement Links o Analog (Voltage/Current) o

Digital

Control Links o Analog (Voltage/Current) o

Digital

The listing above is incredibly redundant, but only if to prove a point to the non-electrical engineers taking this course. The point here is that most all methods of interfacing a T&M system/sub-system are by a means of an analog voltage/current or a digital voltage. This can be simple or complex as required by the interface (e.g. simple:analog voltage value. Complex: USB protocol over two digital lines).

To simplify one last level, all T&M practiced in this course will be analog or digital voltage signals. We may add HW timing on top of this to acquire the values at precise sample rates, but that’s it. No DAQ device communication links will be used in this course, although some DAQ do support it (the cRIO, for example).

Electrical Considerations for Voltage Measurements <Section is Progress>

Noise, Dynamic Range and SNR

Interference o Electrical Isolation ( Power Supply, other channels, EMI)

Linearity

Timing Precision

III.

DAQ MX O VERVIEW

After considering section II, all that DAAQmx really needs to encapsulate is reading and writing analog or digital signals. If we want to get fancy, we might consider adding hardware timing (taking multiple samples at a precise rate), or adding some sort of triggering to start the reading/writing. For digital lines, we might also use counting and/or timers to achieve T&M tasks.

When the API is illustrated in a moment (section V), it will seen that there really is only Create/Read/Write functions at the heart of the DAQmx API. Furthermore, this API uses the concept of polymorphism to use the same create, read and write functions for all NI

T&M hardware, but more on that in a moment. Also take note that there is a tremendous amount of work under the hood of DAQmx to make this all work, but we’re not concerned with this. That’s the beauty of a robust API like DAQmx.

Measurement & Automation Explorer (MAX)

Make no mistake about it; National Instruments is a significant hardware company. In fact, they are the number one commercial manufacturer of DAQ devices in the world. They choose to organize and consolidate all of this hardware within the desktop computer through their Measurement & Automation Explorer software. Take a moment to browse this software. Specifically, if you have a

DAQ, locate it within the Configuration Tree (Figure 4

IV.

DAQ MX – T HE API

The DAQmx API is intended as an abstraction layer between the T&M hardware in use, and the developer using it. A simplified model of this abstraction and logical structure of the T&M development

system is in Figure 1. This section is concerned with how the API presents the hardware to the

developer for implementation. DAQmx presents the HW in a greatly simplified manner, based off of the essential functions for T&M hardware (well ok, there are also more advanced functions. But they are optional).

Initialization

Read Value

Write Value

(DAQmx Create Channel.vi)

(DAQmx Read.vi)

(DAQmx Write.vi)

Timing

Clear Task

(DAQmx Timing.vi)

(DAQmx Clear Task.vi)

Note that the API presents one function that can be configured to control many T&M devices (e.g. the same ‘read’ function is used for two different kinds of DAQs). It is simply a matter of configuring the function to establish which type of HW it accesses (but more on that in a moment). Each function will be discussed momentarily, but first a few notes about their BD implementation are necessary.

DAQmx Polymorphism

As just mentioned, the Create/Read/Write tasks can be configured for use with many types of DAQ operations. This is accomplished by means of the DAQmx Menu Selector. An example of the menu

selector is given in Figure 2. Each functions selector presents a wide range of options for configuration, organized in a tree-like structure. For example, the read function of Figure 2 is configured for a single-

channel, single-sample Analog read, returned as a Double. This type of read is perhaps the standard,

simple read. This selection as navigated through the menu is also shown in Figure 3 below.

Figure 1: Logical Layout of an API.

Figure 2: DAQmx Read

Figure 3: Navigating the Menu Selection.

A Note on the Menu Selection

First, pay attention to what you select; it determines both the type of measurement taken AND the data type of the output terminal. In

Figure 3, the output is a scalar Double (DBL) value. We could choose to output this as a waveform of just one data point if this was

more useful for the code.

V.

DAQM X – A N E XAMPLE

This picture is taken directly from the DAQMx Reference Card on the course site: http://www.justinreina.com/ni/codeExamples/daqMX.

Please visit this folder for working examples of digital and analog IO implementations in the /DAQMx_Templates Folder.

VI.

A F IRST DAQ ROUTINE (RC C IRCUIT )

Before the DAQ is used we must first connect it to the PC. The connection process is first discussed. Luckily this is a highly automated and robust process for all NI hardware; all that is required is for the user to simply plug in the DAQ. NI’s software

(Measurement & Automation Explorer, or MAX ) automatically configures the rest.

DAQ Setup

The connection process is illustrated briefly. After reading through the process, execute it on your own computer. After configuration of the device, take a moment to browse through your device within MAX.

1.

The DAQ is plugged in. The USB drivers first get installed by the computer.

2.

The USB driver is initialized, and calls Automation Explorer to recognize the DAQ, and assign it a name.

3.

MAX assigns the device a name, and performs a ‘Self-Test’ on the device. If this fails, MAX brings up a soft dialogue indicating so. This failure rarely happens though.

4.

Now the device is ready to use, and is visible from LabVIEW. Visibility primarily entails that it’s physical channels are selectable from a physical channels control.

5.

The DAQ is visible within MAX under the ‘Devices & Interfaces->NI-DAQmx Devices’ tree

selection, as seen in Figure 4.

DAQ Icebreaker Code

Next connect the RC circuit to your DAQ. Use the configuration illustrated in Figure 5 below.

Figure 4: Location of Device

within MAX.

Figure 5: RC Circuit Configuration

Take note that the labels ‘Input’ and ‘Output’ are written with respect to the circuit , not the DAQ. The circuit’s input is also the

DAQ’s output. Students often get caught up on this point, so take a moment to make sure you are clear on this syntax. After the circuit is connected, open the ‘DAQ_Icebreaker.vi’ code in today’s session folder, and configure for use with the circuit. Execute the code and note it’s functionality.

VII.

H ARDWARE T IMED DAQ <A DD M ORE C ONTENT TO THIS SECTION >

This section uses hardware timing. An example of hardware timing configuration is provided in the /DAQMx_Templates folder.

Perform the following sequence:

 Wait for a ‘start sliding ‘ button click

Write the slider value at a period of 20ms to Ao.0 for 2 seconds. Use auto-indexing to capture these values

In parallel with the write loop, have a second loop perform a read function, HW timed at 2kS/s. Read 4k data points.

At the output of the write loop, turn this 1D arra y into a waveform datatype. Then plot both the read result and the write result onto the same graph.

<Addendum>

Talk about tasks in the Notecard

Talk about the Physical Channel/Line Constant

Show how to use timing

Download