This reference guide demonstrates how to migrate applications written in Traditional NI-DAQ (Legacy) to NI-DAQ™mx. The purpose of this document is to show the key differences between the two data acquisition (DAQ) drivers, as well as discuss some common tips to use while programming in NI-DAQmx.
NI recommends starting with a new VI and using the old VIs written in Traditional NI-DAQ (Legacy) as a guide. Although many of the programming techniques are similar, there are some slight differences that will be pointed out in this document. Please note that this article is intended to be a supplement to the other help documents available, not a substitution. After you understand what is described in this article, you should have a clear idea of the main differences to keep in mind when programming in NI-DAQmx.
Since it is recommended to start code from scratch, here are a few guidelines and suggestions to make that transition as easy as possible. A helpful tool available since LabVIEW 7.0 and later is the DAQ Assistant. With this assistant, you can designate what you want your code to do in Measurement & Automation Explorer (MAX), and then generate code based on that task. After generating the code, you can then edit it by adding property nodes or changing the configuration to meet the needs of your specific application. If you would like more information on how the DAQ Assistant works, refer to Taking an NI-DAQmx Measurement in LabVIEW.
One major difference between the two drivers is in the palettes. In Traditional NI-DAQ (Legacy), there is a different palette for each type of operation, such as a digital palette for digital operations, an analog input palette for all analog input operations, and so on. In NI-DAQmx, just one set of VIs is used for all operations, and you can configure each VI for a specific type of acquisition. For example, in Traditional NI-DAQ (Legacy), you use the AI Config.vi
to configure a channel or set of channels for analog input. In NI-DAQmx, you use the DAQmx Create Channel.vi
, and configure this VI for Analog Input: Voltage. This distinction makes it easier to become familiar with the specific VIs needed to perform various operations.
This example shows the difference between Traditional NI-DAQ (Legacy) and NI-DAQmx when performing continuous analog input with an internal clock. To translate a program written with Traditional NI-DAQ (Legacy) into NI-DAQmx, follow these steps:
AI Config.vi
with the DAQmx Create Channel.vi
.DAQmx Create Channel.vi
for Voltage by selecting from the dropdown below the VI Analog Input>>Voltage. This information needs to be set because the DAQmx Create Channel.vi
is a polymorphic VI used for all types of acquisition. This is unlike Traditional NI-DAQ (Legacy) where different VIs are used for the different types of acquisitions.DAQmx Timing.vi
after the DAQmx Create Channel.vi
. The DAQmx Timing.vi
sets the sample rate and creates the buffer for continuous acquisition. Since continuous acquisition is specified, LabVIEW automatically creates a buffer to make use of buffered acquisition.AI Start.vi
with the DAQmx Start Task.vi
, which is similar in functionality. The most significant difference between the two is that the sample rate is no longer set when you start the acquisition, but instead set with the DAQmx Timing.vi
.AI Read.vi
with the DAQmx Read.vi
.DAQmx Read.vi
for Analog»Multiple Channels»Multiple Samples»1D Waveform.AI Clear.vi
with the DAQmx Clear Task.vi
. The inputs to this VI are the same and it performs the same function.
This example shows the difference between Continuous Analog Output in Traditional NI-DAQ (Legacy) and NI-DAQmx. To convert a program written in Traditional NI-DAQ (Legacy) to NI-DAQmx, follow these steps:
AO Config.vi
with the DAQmx Create Channel.vi
.Compute Waveform.vi
with a very similar VI called Waveform Buffer Generation.vi
. This new VI passes the task through the waveform generation VI, as opposed to having to wire around it as in Traditional NI-DAQ (Legacy).AO Write.vi
with both the DAQmx Timing.vi
and the DAQmx Write.vi
.DAQmx Timing.vi
for the Sample Clock. The DAQmx Timing.vi
, when configured for the Sample Clock, specifies the sample mode as well as the clock source to use.DAQmx Write.vi
to use Analog»Single Channel»Multiple Sample»Waveform.AO Start.vi
with the DAQmx Start Task.vi
. Both of these VIs have similar inputs and outputs and generally perform the same functions.AO Write.vi
with the DAQmx Is Task Done.vi
. Because this example uses continuous generation, you do not necessarily need to use the DAQmx Is Task Done.vi
because the task will not be complete until you press the stop button on the front panel. However, if you are performing a finite generation, this VI is essential to signify the end of the operation.AO Clear.vi
with the DAQmx Clear Task.vi
. Both of these VIs achieve the same function.
The example above illustrates the difference between doing Digital Port Writes in Traditional NI-DAQ (Legacy) and in NI-DAQmx. To move a Traditional NI-DAQ (Legacy) program to NI-DAQmx, follow these steps:
DIO Port Config.vi
with both the DAQmx Create Channel.vi
and the DAQmx Start Task.vi
.DAQmx Create Channel.vi
for Digital Output.DAQmx Write.vi
.DAQmx Write.vi
for Digital»Single Channel»Single Sample»U8 (Port Format). This VI takes care of writing all the data.DAQmx Clear Task.vi
outside the while loop to clear the task created for the program.
This example demonstrates the difference between doing Continuous Pulse Train Generation in Traditional NI-DAQ (Legacy) and NI-DAQmx. Follow these steps to transition a program written in Traditional NI-DAQ (Legacy) to NI-DAQmx.
Counter Group Config.vi
with the DAQmx Create Channel.vi
.DAQmx Create Channel.vi
for Counter Output»Pulse Generation»Frequency.Set Pulse Specs.vi
is no longer needed because those values are set on the DAQmx Create Channel.vi
instead.Counter Gate (STC).vi
with a DAQmx Trigger property node. Set the Trigger Type to Digital Level in the property node, and then create a control on the front panel to select the source of the gate.DAQmx Timing.vi
after the DAQmx Trigger property node. The DAQmx Timing.vi
is configured to Implicit (Counter). This VI indicates the duration of the pulse generation.DAQmx Timing.vi
. In this case, the timing property node specifies the onboard clock and configures an external clock, if desired. This is used in lieu of the case structure in the Traditional NI-DAQ (Legacy) example.Counter Control.vi
with a DAQmx Is Task Done.vi
inside the while loop. The purpose of this VI is to check when finite generation is finished. For this example, the DAQmx Is Task Done.vi
can be omitted since it is continuous, but if performing finite generation, you need to include this VI.Counter Control.vi
with the DAQmx Clear Task.vi
. The inputs to this new VI are very similar, except that the task automatically resets without specifying to do so.
This example illustrates how to synchronize a 653X board with an E Series board. The REQ clock of the 653X is used as the sample clock for an analog input acquisition on the E Series board. This is shown above using Traditional NI-DAQ (Legacy) as well as NI-DAQmx. The example demonstrates the flexibility and the interoperability of the two drivers, and how much clearer RTSI use is in NI-DAQmx. The digital board portion on both examples uses the Traditional NI-DAQ (Legacy) driver, so this explanation describes only how to convert the segment of code running on the E Series board.
AI Config.vi
with theDAQmx Create Channel.vi
.DAQmx Create Channel.vi
for Voltage by selecting from the dropdown below the VI Analog Input»Voltage.AI Clock Config.vi
with the DAQmx Timing.vi
. The DAQmx Timing.vi
sets the sample rate and creates the buffer, because continuous acquisition is desired. The buffer is acquired automatically since it is set up for continuous acquisition. One important input to this VI is the Source. Leave the input blank if you want to use the default onboard clock. For this example, however, create a constant and set it to use the RTSI pin that is routed from the digital board (which in this case is /Dev4/RTSI0). Notice that this name permits you to specify a different device number. This is important because NI-DAQmx accomplishes all the internal routing for you.AI Control.vi
with the DAQmx Start Task.vi
, which is similar in functionality.AI Read.vi
with the DAQmx Read.vi
.DAQmx Read.vi
for Analog»Single Channel»Multiple Samples»1D Waveform. You must provide this information because the DAQmx Read.vi
is a polymorphic VI used for all types of data acquisition (as opposed to Traditional NI-DAQ (Legacy), where there are many unique VIs for different types of acquisition).AI Clear.vi
with the DAQmx Clear Task.vi
. The inputs to this VI are the same and they perform the same functionality.