Use the I/O controls on the I/O and Classic I/O palettes to specify the instrument or device resource you want to communicate with. Use the VIs on the Measurement I/O palette to develop DAQ applications.
Complete the following basic programmatic steps to create a DAQ application.
Notice that timing and triggering are optional. Include the timing step if you want to specify hardware timing instead of software timing. If you are using NI-DAQmx, you can use the DAQ Assistant to set timing parameters for a task.
|Note (Windows) LabVIEW supports NI-DAQmx and the DAQ Assistant. (Mac OS X) LabVIEW supports NI-DAQmx Base but not the DAQ Assistant. (Linux) LabVIEW supports NI-DAQmx but not the DAQ Assistant.|
Use triggering if you want the device to acquire samples only when certain conditions are met. For example, you might want to acquire samples if the input signal goes higher than 4 V. If you are using NI-DAQmx, you can use the DAQ Assistant to configure triggering for a task.
Many NI-DAQmx applications also can include steps to start, stop, and clear the task. For example, for applications that use a counter/timer to count edges or to measure period, use the Start VI to arm the counter.
In NI-DAQmx, LabVIEW clears the task automatically when the VI hierarchy that created the task finishes executing.
Traditional NI-DAQ (Legacy) and NI-DAQmx include VIs for timing, triggering, reading, and writing samples. Use the Data Acquisition VIs and Functions to acquire data from DAQ devices. To use these VIs, you must have the NI-DAQ driver software and DAQ hardware installed. After you acquire data, you can use the built-in Signal Processing, Report Generation, and Mathematics VIs and functions to analyze, generate reports, and perform mathematical operations on that data.
You can use the NI-DAQmx properties to extend the functionality of the NI-DAQmx VIs.
Many of the Traditional NI-DAQ (Legacy) and NI-DAQmx VIs are polymorphic and can accept or return data of various types, such as scalar values, arrays, or waveforms. You use other polymorphic NI-DAQmx VIs to configure various triggers and methods of sample timing, and to create virtual channels. By default, NI-DAQmx VIs appear with the polymorphic VI selector.
A physical channel is a terminal or pin at which you can measure or generate an analog or digital signal. Every physical channel on a device that supports NI-DAQmx has a unique name.
A virtual channel is a collection of property settings that can include a name, a physical channel, input terminal connections, the type of measurement or generation, and scaling information. In Traditional NI-DAQ (Legacy) and earlier versions, configuring virtual channels is an optional way to record which channels are being used for different measurements, but virtual channels are integral to every NI-DAQmx measurement.
A task in NI-DAQmx is a collection of one or more virtual channels with timing, triggering, and other properties. A task represents a measurement or a generation you want to perform. You can set up and save all of the configuration information in a task and use the task in an application.
In NI-DAQmx, you can configure virtual channels as part of a task or separate from a task.
Complete the following steps to perform a measurement or a generation with a task.
Repeat steps 2 and 3, if it is appropriate for the application. For example, after reading or writing samples, you can reconfigure the channel, timing, or triggering properties and then read or write additional samples based on this new configuration.
Use the waveform control, the digital waveform control, the waveform graph, and the digital waveform graph to represent the waveforms and digital waveforms you acquire or generate. LabVIEW represents an analog waveform, such as a sine wave or a square wave, with the waveform data type by default. A 1D array of waveform data type represents multiple waveforms. LabVIEW represents a digital waveform with the digital waveform data type by default.
The waveform and digital waveform controls consist of components that include a start time, a delta t, the waveform data, and attributes. Use the Waveform VIs and functions to access and manipulate individual components.
The start time (t0) is a time stamp associated with the first measurement point in the waveform. Use the start time to synchronize plots on a multi-plot waveform graph or digital waveform graph and to determine delays between waveforms. Delta t (dt) is the time interval in seconds between any two points in the signal. The waveform data and the digital waveform data are the values that represent the waveform. An array of any numeric data type other than the fixed-point numeric data type can represent analog waveform data. Generally, the number of data values in the array corresponds directly to the number of scans from a DAQ device. The digital data type represents a digital waveform and displays the digital data in a table. Attributes include information about the signal, such as the name of the signal and the device acquiring the signal. NI-DAQ automatically sets some attributes for you. Use the Set Waveform Attribute function to set attributes, and use the Get Waveform Attribute function to read attributes.
|Note If you convert the waveform data type to the dynamic data type, you can set and read attributes of the dynamic data by using the Set Dynamic Data Attributes Express VI and the Get Dynamic Data Attributes Express VI, respectively. These Express VIs automatically convert the dynamic data type to the waveform data type before you can set and read attributes. The dynamic data type is for use with Express VIs.|
To represent waveform data in the front panel window, use the waveform control or the waveform graph. To represent digital waveform data, use the digital waveform control or the digital waveform graph.
Use the waveform control and the digital waveform control to manipulate the t0, dt, and Y components of the waveform or to display those components as an indicator. When you wire a waveform to a graph, the t0 component is the initial value on the x-axis. The number of scans acquired and the dt component determine the subsequent values on the x-axis. The data elements in the Y component comprise the points on the plot of the graph.
If you want to let a user control a certain component, such as the dt component, create a front panel control and wire it to the appropriate component in the Build Waveform (Analog Waveform) function.
If you want to organize digital waveform data into a digital waveform array, use the Group Digital Signals Express VI.
You can use several VIs to accept, operate on, and/or return waveforms. In addition, you can wire the waveform data type directly to many controls, including the graph, chart, numeric controls, and numeric array controls.
The AI Acquire Waveform VI acquires a specified number of samples at a specified sample rate at a particular time from a single input channel and returns a waveform. The Digital IIR Filter VI accepts an array of waveforms and filters the data of each waveform. The AI Sample Channel VI acquires a single sample from a channel and returns a single-point waveform. The Sine Waveform VI generates a sine waveform, and the AO Generate Waveform VI sends a waveform to a device.
Use the Get Waveform Components (Analog Waveform) function to extract and manipulate the components of a waveform you generate. The Negate function negates waveform data and plots the results to a graph.
Use the Digital Waveform VIs and functions to manipulate digital data by extracting and editing the components of the digital signal. Use the NI-DAQmx VIs on the Digital I/O palette to acquire and send a digital signal. The Digital Waveform palette also includes VIs that convert analog data to digital signals, search a digital signal for a pattern, append a digital signal(s) to another digital signal, and perform other digital tasks.
Refer to the Taking an NI-DAQmx Measurement in LabVIEW tutorial for more information about creating typical DAQ applications.