NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf ·...

41
NI-DAQmx Basic Course NITS 2005 John Shannon

Transcript of NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf ·...

Page 1: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

NI-DAQmx Basic CourseNITS 2005

John Shannon

Page 2: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Agenda• Intro to DAQMX

– Difference between traditional / DaqMX– MAX and DAQ Assistance

• Analog Input / Output– Property Nodes– Buffered / Continuous Acquisition– Analog Output– Triggering

• Counter / Timers– Counter Timer Concepts

Page 3: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

What is NI-DAQmx?• Driver level software

– DLL that makes direct calls to your DAQ device• NI-DAQ does not support 3rd party Data Acquisition devices• Supports the following National Instruments software:

– LabVIEW– Measurement Studio

• Also supports the following 3rd party languages:– ANSI C ─ Borland C++– Microsoft C/C++ ─ Borland Delphi– Visual Basic

• Subset of NI-DAQmx can run under other Operating Systems– MAC OS X– Linux

Page 4: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

NI-DAQmx Measurement Services Software

LabVIEW

ConfigurationManager

(MAX)

DAQ Assistant

API

Driver Engine

Hardware

Measurement Services: More than just a driver• Streamlined API

– Polymorphic functions– Automatic code generation– Simple and intuitive API

• Improved Driver Architecture– Multithreaded measurements– Easy, Instant calibration– 20x faster for single-point operations– Code generation

Page 5: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

April 20025

Measurement and Automation Explorer (MAX)

Device configuration

and connection management

Built-in test panel windows

Task and channel creation

Signal connection diagrams

Page 6: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQ Assistant• A step-by-step guide that helps

you configure DAQ tasks, virtual channels, and scales with zero programming.

• Can be launched by right clicking on DAQmx controls.

• DAQ Assistant Express VI (local to application, not in MAX)

• MAX, right click Data Neighborhood and select Create New.

Page 7: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Physical & Global Channels in MAX

Physical Channels– Terminal of pin at which you can measure or generate an analog or

digital signal.– Hardware level

Global Channels– Global channels configured in MAX or application through DAQ

Assistant.– Can be used in any application or added to any task.– If you modify a global channel, it will affect all tasks in which it is used.

Page 8: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

NI-DAQmx TaskA collection of one or more local or global virtual channels with timing, triggering, and other properties included.

Page 9: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Example 1 – Explore MAX• Run Test Panels• Configure a Global Channel,

Scale, and Task

KF2

Page 10: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Slide 9

KF2 need to add B & C portions to this exercise that show calibration, import/export wizardKristi Fairchild, 11/23/2004

Page 11: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Programming with NI-DAQmx and LabVIEWFlexible programming options:• DAQ Assistant

– Creating Tasks and Channels in MAX– DAQ Assistant Express VI– DAQmx Task Name

Constant• Automatic code generation• NI-DAQmx API

– DAQmx VIs– DAQmx Property Nodes

Page 12: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Example 2 – Measuring Voltage in LabVIEW

Using the DAQ Assistant Express VI

KF3

Page 13: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Slide 11

KF3 need to add B & C portions to this exercise that show calibration, import/export wizardKristi Fairchild, 11/23/2004

Page 14: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

April 200212

NI-DAQmx - VI’s & Property Nodes in LabVIEW

Core Polymorphic VIs

Property Nodes

Advanced Utility Functions

DAQ Assistant

NI-DAQmx Task and Channel Constants

Page 15: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Property Nodes• NI-DAQmx uses these LabVIEW

constructs to provide complete programmatic control for all properties supported by the NI-DAQmx API.

• NI-DAQmx also provides a set of VIs that you can use to write your application, they are equivalent but easier and more convenient to use.

• The two examples are functionally equivalent.

Page 16: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Read VI & Read Property Node

• Properties include– Offset– Channels to Read– Waveform Attributes– Status – Current Sample #– Advanced – Raw Data Width– And many more!

• Read VI– Used for analog, digital, counter, and raw data– Single or multiple channels and samples

Page 17: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Write VI & Write Property Node

• Properties include–Position–Offset–Regeneration Mode–Status – Space Available in Buffer–Advanced – Raw Data Width–And many more!

• Write VI– Used for analog, digital, and unscaled data– Single or multiple channels and samples

Page 18: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

PCI Bus

RAM

PCBuffer

ADE (Application)Memory

Input Rate

DATA

Onboard FIFO Memory

Transfer Rate

ASIC

LabVIEW

Data Transfer for an Input Operation

Page 19: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Finite Buffered Acquisition• Perform a hardware-timed, finite buffered acquisition• Set the buffer size, sampling mode, sampling rate, and number of

samples to read per channel• Number of samples per channel equals the buffer size or configure with

Configure Input Buffer VI.

NSamp = Multiple Samples

Configure buffer, sampling mode,

and rate

Page 20: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Continuous Buffered Acquisition

Select continuous samples for sample

mode

While loop around DAQmx Read

Available samples per channel = # available to read

Set buffer size

• If Num of samples per channel is unwired or set to -1, DAQmx automatically determines how many samples to read, based on taskconfiguration.

Page 21: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Analog Output• Set the buffer size, sampling mode, sampling rate, and number of

samples to read per channel.• Number of samples per channel equals the buffer size.• Can be set with either the DAQmx Timing VI or with Configure Input

Buffer VI.

Page 22: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Example 2

Analog Input

Page 23: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Trigger VI & Trigger Property Node• Properties include

– Start Trigger Type– Start Digital Edge Source– Start Analog Window Top– Reference Pre-Trigger

Samples per Channel– Reference Analog Edge

Slope– And many more!

• Trigger VI– Configures the task to

start or stop on a rising orfalling digital edge, analog edge, or analog windows

Page 24: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Triggering – Digital Triggering

Trigger Signal

Input Signal

Acquired Signal

Page 25: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Triggering – Analog Triggering

Trigger Signal

Input Signal

Acquired Signal

Trigger Threshold

Page 26: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Counter Applications• Edge Counting

– Simple Edge Counting– Time Measurement

• Pulse Generation– Single Pulse Generation– Pulse Train Generation

• Pulse Measurement– Period Measurement– Pulse Width Measurement

• Frequency Measurement• Position Measurement

Gate

Source

Out

Count Register

Page 27: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Source and Gate Selectors

• Source and gate selection is seamless– The terminology “morphs” depending on the specific application– You only need to specify the input terminal for your measurement and

DAQmx will connect it to the appropriate source or gate depending on the application

• Counter signals can be input on any PFI pins• DAQ Assistant will give you the default PFI pin for the

application

Page 28: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Simple Edge Counting

• Use the Counter instance of the DAQmx Read VI

Start Task

Count Edges

StopTask

Page 29: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Pause Trigger Edge CountingPause trigger is set with DAQmx

Trigger property node

Create Virtual Channel Start Task

Count Edges

Stop Task

Page 30: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Example 4 – Simple Event Counting

Page 31: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

The Latest and Greatest Features of NI-DAQmx

• USB Support (7.5)• Simulated Devices (7.4)• Virtual Channel Calibration (7.4)• Ability to Programmatically Save Tasks/Channels/Scales to

MAX (7.4)• Connection Diagram Report Generation (7.4)• Continual Addition of Example Programs

Page 32: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Questions?

Page 33: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Virtual ChannelsVirtual Channels• Are a collection of settings that can include a name, a physical

channel, input terminal connections, type of measurement / generation and scaling info.

• Can be configured with DAQ Assistant (MAX or Application)• Can also be configured through the DAQmx API in your

application (DAQmx Create Virtual Channel VI).• Virtual channels created inside a task are local channels.• Virtual channels defined outside a task are global channels.

Page 34: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

NI-DAQmx Simulated Devices• Run NI-DAQmx programs and Assistant

without the hardware! • Assistant and programs run just like on a

real device with some exceptions:– Timing and triggering are instantaneous– Reads return fake data (for AI, data is a sine

wave with some noise)• Works for any supported DAQmx Device

(DAQmx Plug-in Devices, SCXI, SCC’s, etc.)

Page 35: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Virtual Channel Calibration • Complete end-to-end calibration• Analog Input only• Multi-channel if all same type• All done in software• Can be combined with all other

scaling types: measurement, device-cal, TEDS, custom scales, etc.

Page 36: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Create Virtual Channel VI & Channel Property Node• Properties include

– Channel Type– Physical Channel Name– Description– Analog I/O Custom Scale Name– Digital I/O Number of lines– Counter I/O Pulse Duty Cycle– And many more!

• Create Virtual Channel VI– Programmatic creation of virtual

channel(s)– Adds the created channel(s) to a

specified task

Page 37: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Analog Output

• DAQmx allows single-point, buffered, continuous, or triggered generation.

• The ‘Use Waveform’ instance of the DAQmx Timing VI allows you to generate a waveform data type

• Output waveform frequency depends on update rate and the number of cycles of the waveform in the buffer

Page 38: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Virtual Channel Counter Options

Frequency Instance Time Instance Ticks Instance

Page 39: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

DAQmx Read Function

Signal TypeSingle or Multiple

Channels?

Single or Multiple

Samples?

Return data as waveform or

double (array) type?

1. Select Settings

2. Verify SettingsAnalog1 Channel1 SampleWaveform

Page 40: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Reference Trigger

Pre-trigger data

Post-trigger data

Start acquire

Reference Triggering• Acquisition starts as soon as software is started• Data in the buffer keeps getting overwritten (first in first out)

until the stop trigger is received • Typically only for finite input operations• Post-trigger Data =

Size of Buffer – Pre-trigger Data

Page 41: NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf · What is NI-DAQmx? • Driver level software – DLL that makes direct calls to your

Advanced Trigger Method: Pause Triggering• Allows you to pause an acquisition/generation• Operation stops when trigger signal is low and resumes when trigger

signal is high

Analog Pause Trigger:

Digital Pause Trigger: