NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf ·...
Transcript of NITS 2005 DAQmx - National Instrumentsdownload.ni.com/pub/techsym/rochester/intro_to_daqmx.pdf ·...
NI-DAQmx Basic CourseNITS 2005
John Shannon
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
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
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
April 20025
Measurement and Automation Explorer (MAX)
Device configuration
and connection management
Built-in test panel windows
Task and channel creation
Signal connection diagrams
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.
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.
NI-DAQmx TaskA collection of one or more local or global virtual channels with timing, triggering, and other properties included.
Example 1 – Explore MAX• Run Test Panels• Configure a Global Channel,
Scale, and Task
KF2
Slide 9
KF2 need to add B & C portions to this exercise that show calibration, import/export wizardKristi Fairchild, 11/23/2004
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
Example 2 – Measuring Voltage in LabVIEW
Using the DAQ Assistant Express VI
KF3
Slide 11
KF3 need to add B & C portions to this exercise that show calibration, import/export wizardKristi Fairchild, 11/23/2004
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
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.
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
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
PCI Bus
RAM
PCBuffer
ADE (Application)Memory
Input Rate
DATA
Onboard FIFO Memory
Transfer Rate
ASIC
LabVIEW
Data Transfer for an Input Operation
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
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.
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.
Example 2
Analog Input
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
Triggering – Digital Triggering
Trigger Signal
Input Signal
Acquired Signal
Triggering – Analog Triggering
Trigger Signal
Input Signal
Acquired Signal
Trigger Threshold
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
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
DAQmx Simple Edge Counting
• Use the Counter instance of the DAQmx Read VI
Start Task
Count Edges
StopTask
DAQmx Pause Trigger Edge CountingPause trigger is set with DAQmx
Trigger property node
Create Virtual Channel Start Task
Count Edges
Stop Task
Example 4 – Simple Event Counting
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
Questions?
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.
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.)
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.
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
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
DAQmx Virtual Channel Counter Options
Frequency Instance Time Instance Ticks Instance
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
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
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: