DAQmx
description
Transcript of DAQmx
uk.ni.comireland.ni.co
m
DAQmx
Alistair Bailey – Field Engineer
2uk.ni.com
ireland.ni.com
What is DAQmx?At it’s core, DAQmx is a powerful hardware driver for controlling data acquisition hardware.
Hundreds of DAQ Devices
DAQ Hardware
USB, PXI Express, PCI ExpressBus
NI-DAQmxHardware Driver
LabVIEW, C, .NETApplication Software
3uk.ni.com
ireland.ni.com
DAQmx Core ConceptsGlobal Virtual Channel
Contains the physical channel and other channel-specific informationTask
A collection of one or more channelsFunctions
Performs a specific function in DAQmxProperties
Control or set specific properties of your DAQmx session
4uk.ni.com
ireland.ni.com
1. DAQ Assistant• The DAQ Assistant is a
configuration-based interface for controlling your DAQ instruments
• You can configure things like:
• Channels• Voltage ranges• Sampling rate• …and many other aspects
of your measurement
6uk.ni.com
ireland.ni.com
2. Create Virtual ChannelCreates a virtual channel and adds it to a DAQmx task. If a task doesn’t exist, it creates one.
7uk.ni.com
ireland.ni.com
2. Create Virtual ChannelCreates a virtual channel and adds it to a DAQmx task. If a task doesn’t exist, it creates one.
Channel Expansion across modules in a PXI chassis
8uk.ni.com
ireland.ni.com
3. TriggerConfigures a trigger to perform a specific action. The most common actions are a start trigger and reference trigger.
9uk.ni.com
ireland.ni.com
4. TimingConfigures the timing for hardware-timed data acquisition.
10
uk.ni.comireland.ni.co
m
4. TimingConfigures the timing for hardware-timed data acquisition.
The DAQmx Task BufferTemporary storage in computer memory for acquired or to-be-
generated samples
11
uk.ni.comireland.ni.co
m
5. Start TaskStarts your task. The task is now in the running state.
12
uk.ni.comireland.ni.co
m
DAQmx Task State Model
Unverified Verified Reserved Committ
ed Running
AbortAbort
Abort
Create Verify Reserve Commit Start
Unreserve StopSetClear
13
uk.ni.comireland.ni.co
m
6. ReadReads samples from the acquisition task.
The Read function adapts to different data types and channel counts
Start your task and read data
14
uk.ni.comireland.ni.co
m
7. WriteWrites samples to the generation task.
The Write function adapts to different data types and channel counts
Write data, then start your task
15
uk.ni.comireland.ni.co
m
8. Wait Until DoneWaits for the data acquisition operation to complete before finishing.
16
uk.ni.comireland.ni.co
m
9. Clear TaskClears the task, and releases all of the resources. If the task needs to be reused, use Stop Task instead.
After the DAQmx read, clear the task.
17
uk.ni.comireland.ni.co
m
10. PropertiesAccess all of the properties associated with DAQmx. Properties can by written to or read.
DAQmx TimingQuery the actual sample rate
DAQmx ChannelSpecify which terminal pules
18
uk.ni.comireland.ni.co
m
Why Use the API?Advanced control over your measurement
system
Multiple Language Support
Task and State Management
Multi-device Synchronization
Advanced Application Architectures
Ability to provide even better performance
20
uk.ni.comireland.ni.co
m
Example 1 – Multi Channel Analog OutputTwo ChannelsDifferent Frequencies
Fundamentals:•The sample rate is the “update rate” of the DACThe only variable we can play with is the number of samples in our waveform.•Use “interpolation” and “decimation” to modify the frequency of one independently.
21
uk.ni.comireland.ni.co
m
Output Waveform FrequencyOutput waveform frequency depends on three factors:
• Update rate• Points in the buffer• Number of cycles
in the buffer
Signal Frequency = update rate
points in the buffer# of cycles in buffer X
22
uk.ni.comireland.ni.co
m
Output Waveform Frequency• Buffer size = 1000 pts• # of cycles in buffer = 1• Update rate = 1000 Hz
• Buffer size = 1000 pts• # of cycles in buffer = 1• Update rate = 2000 Hz
• Buffer size = 1000 pts• # of cycles in buffer = 2• Update rate = 1000 Hz
Signal frequency = 1 Hz
Signal frequency = 2 Hz
Signal frequency = 2 Hz
Signal Frequency = update ratepoints in the buffer
# of cycles in buffer X
23
uk.ni.comireland.ni.co
m
Demo
24
uk.ni.comireland.ni.co
m
Example 2 – Simultaneous AI & AOOptions:1. Independent of each other
1. All hardware with hardware timed AO2. cDAQ with STC-3
2. Start together1. Use the same hardware trigger for AI & AO on the
trigger VI3. Same clock (preserves phase relationship)
1. Use the same sample clock on the timing VI
25
uk.ni.comireland.ni.co
m
Demo
uk.ni.comireland.ni.co
m
Questions?