Advanced Data Acquisition Techniques with Intelligent DAQ
Overview
Intelligent DAQ is multifunction data acquisition that features user-defined, onboard processing for complete flexibility of system timing and triggering. Instead of a fixed ASIC for controlling device functionality, intelligent DAQ uses an FPGA-based system timing controller to make all analog and digital I/O configurable for application-specific operation. This tutorial will show how to implement completely flexible and customized data acquisition tasks using R Series intelligent DAQ boards and LabVIEW FPGA.
Table of Contents
Introduction
Using the National instruments LabVIEW FPGA module, DAQ system developers have complete flexibility when programming an application for any type of input/output operation. Without having any prior knowledge of hardware design tools such as VHDL, you can embed LabVIEW code onto an FPGA chip and achieve true hardware-timed speed and reliability.
Let’s begin by addressing the common components of data acquisition hardware. Assuming you’ve got analog-to-digital converters (ADCs), digital-to-analog converters (DACs), and digital input/output lines, all of the I/O needs to be timed and controlled somehow for actual operation. Typical multifunction data acquisition devices use a feature-rich ASIC that incorporates the majority of needs in functionality. An M Series DAQ device, for example, uses the DAQ-STC2 to control timing and triggering amongst the various hardware components. Intelligent DAQ hardware, such as R Series DAQ devices, is differentiated from all other data acquisition devices on the market because instead of a fixed ASIC for controlling device functionality, intelligent DAQ uses an FPGA-based system timing controller to make all analog and digital I/O configurable for application-specific operation. The reconfigurable FPGA chip is programmed with the LabVIEW FPGA Module, where the LabVIEW dataflow paradigm still applies, but with a new set of functions that control device I/O at the lowest level. Instead of abstracting out common tasks and functions with the NI-DAQmx functions, LabVIEW FPGA I/O nodes will work at the most fundamental level with complete flexibility on all channels. In the following sections, we will examine specific NI-DAQmx examples and explore how to customize various data acquisition tasks using intelligent DAQ.
Timing and Triggering
The most common use of intelligent DAQ for advanced data acquisition is custom timing and triggering. Below is an example block diagram of a triggered analog input task using NI-DAQmx.
Instead of using different functions for channel configuration, as shown in Figure 1, intelligent DAQ uses functions called I/O nodes for the reading and writing of all analog and digital channels. Let’s look at the exact same functionality using I/O nodes in LabVIEW FPGA.
You can see that there are no configuration functions for global channels, sample clocks, triggers, or starting, stopping and clearing tasks. It’s all been replaced by a simple analog I/O read, and all timing is controlled by native LabVIEW structures such as while loops and case structure s. Because the entire block diagram executes in FPGA hardware, the LabVIEW code executes with hardware-timed speed and reliability. Let’s look a little deeper into how this block diagram works. Instead of specifying a particular sampling rate, the analog I/O node uses the For Loop to acquire each sample. The corresponding ADC actually digitizes the input signal when the I/O node is called, and is therefore clocked by the For Loop. If you wanted to sample a signal at 100kHz, the delay specified for that loop should be set to 10 µs. The loop timer function ensures a specific delay in time, beginning with the second loop iteration, so we’ve used a sequence structure to ensure the specified time period between samples. The case structure in LabVIEW FPGA is very powerful, because it essentially represents a hardware trigger for all the code it encapsulates. With all functions and structures executing in hardware with gates of logic, the case structure will ensure that the sampling begins at the correct moment in time, within 10 µs of accuracy. Lastly, there is no need to clear the task ID, or release memory since we are now working at the hardware level, with very few layers of abstraction.
The true benefits to using FPGA-based, intelligent DAQ hardware are the ability to customize all timing and triggering, as well as implement signal processing and decision making in hardware. Let’s now see what it takes to modify our analog input trigger for some custom application. What if we wanted to trigger the acquisition if either of two analog input channels exceeded a certain threshold? This is fairly simple to implement in LabVIEW FPGA.
You’ll see that we’ve added a second I/O node and a second compare function, as well as a Boolean OR function to the block diagram. Intelligent DAQ hardware has dedicated ADCs on every analog input channel, so both channels will be sampled simultaneously, and if either of those exceeds the specified limit the case structure will execute the true case and begin the acquisition within the same 10 µs of accuracy. Keep in mind that it’s not possible to generate a trigger like this without intelligent DAQ, and on other DAQ hardware this would require software-timed decision making with much higher latency. If we wanted to then expand this from monitoring two channels to all eight channels, or even add digital triggers, the customized code wouldn’t be any more complicated. Adding pretrigger scans would involve constantly sampling the input channel and passing data into a FIFO buffer. Once the trigger was read that FIFO buffer and subsequent samples would then be passed to the host through a DMA channel.
If we wanted to sample a second analog input channel using the NI-DAQmx driver, the block diagram wouldn’t be much different than what is shown in Figure 1. There would still be limitations, however, because both channels would be forced to reference the same trigger and sample at the same clock rate. Let’s look at the different options for sampling multiple channels using intelligent DAQ and LabVIEW FPGA.
Figure 4 (above) shows us how to simultaneously sample from two different analog input channels, based on an analog trigger from AI channel 0. Since all intelligent DAQ devices have independent ADCs, two channels within an I/O node will be sampled at the exact same instant. Typical multifunction DAQ devices will multiplex all channels through a single ADC, and therefore all channels must share the same sample clock and trigger lines. Figure 5 (below) shows that intelligent DAQ hardware can actually sample different analog input channels at independent rates. By placing the analog input I/O nodes within independent loops, each channel can sample at completely different rates, and then stream data independently through two DMA channels.
Lastly, if we wanted both channels to have independent sampling rates, as well as independent start triggers, we could place each I/O node in parallel loop structures as shown in Figure 6. This takes full advantage of FPGA parallelism, where each task will use its own dedicated resources and execute completely independent of any other acquisition task.

[+] Enlarge Image
Figure 6. Independently Triggered, Multirate Analog Input with Intelligent DAQ
Synchronization
There are many synchronization options built into the DAQmx driver for correlating inputs and outputs in time. Below is the block diagram of an analog input channel and analog output channel synchronized with a digital start trigger, done by specifying a digital trigger for the analog input and using the analog input start trigger signal to trigger the analog output generation.
To implement the same synchronization scheme with intelligent DAQ hardware is fairly simple without the need for task IDs and onboard signal routing. Here’s how this would look in LabVIEW FPGA.
Once again we’re using the case structure to implement a hardware trigger on the FPGA chip, and a rising edge on digital channel 0 initiates code in the true case. The analog input and output nodes are called simultaneously within the sequence structure with almost no jitter, and if we wanted them to have independent rates, we could easily place the analog I/O nodes in their own separate while loops. It’s also important to note that the sine generator function shown in this block diagram is an express VI with which you can interactively configure the sine values in a look-up table.
The intelligent DAQ block diagram shown in figure 8 will have the same functionality as the DAQmx VI in figure 7, but if we wanted to customize this task, only intelligent DAQ would provide the flexibility to do so. If we needed to add a pause trigger, for example, it could be easily accomplished by adding a Case Structure within the inner While Loop and using another digital I/O node to select a true or false case. The power to program hardware provides endless possibilities for I/O timing and synchronization.
Another example of multifunction synchronization is generating finite pulses with the onboard counters and using the counter output as the analog input sample clock. This process is the common approach to implementing a retriggerable finite sample acquisition. Below is the required DAQmx code for such an acquisition.
Now let’s compare this to a LabVIEW FPGA block diagram with the same functionality.

[+] Enlarge Image
Figure 10. Retriggerable Finite Analog Input with Intelligent DAQ and LabVIEW FPGA
It’s obvious in Figure 10 that there are far less driver configuration steps due to the fact that the LabVIEW code executes in hardware. With a simple digital input line and for loop structure, we’ve created hardware-retriggerable finite acquisition. The previous block diagram in Figure 9 uses two onboard counters to create the retriggerable finite pulse train, and typical multifunction DAQ devicess have only two counters to work with. Intelligent DAQ hardware, however, can configure any digital line to be a counter using LabVIEW FPGA. We’ll cover more on counter/time implementations with intelligent DAQ in a later section.
We could take the hardware-timed flexibility of intelligent DAQ one step further with a frequency-triggered acquisition. While this isn’t possible with a typical multifunction DAQ device, the high-speed onboard decision making can be used to calculate the frequency of an input signal and then select the desired code within a case structure . For multiple device synchronization, intelligent DAQ can also use the RTSI bus for PCI boards or the PXI trigger bus for PXI modules. These external timing and synchronization lines can also be accessed through I/O nodes on the block diagram.
Analog Waveform Generation
Many multifunction DAQ devices have analog output channels that implement a FIFO buffer for continuous analog waveform generation. The waveform being generated can use the FIFO as a circular buffer, and continuously regenerate a series of analog values without any further updates from the host. This relies less on the availability of the communications bus, since data isn’t constantly being streamed to the device. If the waveform needs to be modified, however, the output task must be restarted in order to write new data to the FIFO. The other option is to continuously stream data to the hardware FIFO, which can lead to latencies in your output task. Intelligent DAQ gives you the ability to store the waveform outputs in hardware, and even use hardware triggering to change waveforms, thereby creating an arbitrary waveform generator.
Below is an example of a function generator that uses digital input lines to trigger changes in the output waveform. Based on the combination of digital I/O lines 0 and 1, we get four different states, or cases for analog output.

[+] Enlarge Image
Figure 11a. Function Generator with Intelligent DAQ Case 0 – Zero Output

[+] Enlarge Image
Figure 11b. Function Generator with Intelligent DAQ Case 1 – Sine Wave
If both lines are low, Case 0 is executed and as shown in Figure 11a, the output will be a constant value of 0 V. If DIO line 0 is high and DIO line 1 is low, Case 1 will execute and generate a sine wave on analog output 0. This sine generation case (Figure 11b) uses the sine generator express VI with which you can interactively configure a sine waveform with the required integer values in LabVIEW FPGA.
Case 2 (Figure 11c) simply toggles a Boolean value on every iteration of the while loop. If the value is low, integer 15000 is written to the analog output 0, which corresponds to value 15000 in the output register of a 16-bit DAC. A signed 16-bit integer can have values between -32768 and 32767. With an output range of -10 to 10 V, writing -32768 to analog output 0 will generate -10 V, and writing 32767 will generate 10 V. In this example we’re writing 15000, which will output just under 5 V. (Here’s the math: 15000/32767 * 10 V = 4.5778 V) Basically, Case 2 will output a square wave that toggles between 0 and 4.578 V.
The last case (Figure 11d) will execute if both DIO 0 and DIO 1 are high, and this uses a look-up table to continuously generate a sawtooth wave. The look-up table VI is another express VI with which you can store arbitrary waveform values and index through them programmatically. In this example we’ve configured a sawtooth wave to be generated on analog output channel 0.
By storing all values on the FPGA, you eliminate the dependency of bus availability, as well as ensure hardware-timed speed and reliability on waveform updates. All of the triggering and synchronization flexibility described with analog input in earlier sections also applies to analog output, and with intelligent DAQ you can update different analog output channels at different rates, completely independent of each other. This means you can modify the frequency of a single periodic waveform without affecting the outputs of other channels. Keep in mind that this functionality is not possible on most data acquisition hardware.
See Also:
Arbitrary Waveform Generation with RIO-Enabled Hardware and the LabVIEW FPGA Module
Counter/Timer Operations
As mentioned earlier, typical multifunction DAQ devices only have two onboard counters, whereas intelligent DAQ can implement counter functionality on any available digital line. Digital I/O nodes can take advantage of the specialized structure called the single-cycle timed loop in LabVIEW FPGA, with which you can execute code at specified rates ranging from 2.5 to 200 MHz. Using a 40 MHz clock, for example, you can use a single-cycle timed loop to create a 40 MHz counter on any digital line. Figure 12 (below) is an example of what the block diagram may look like.
Because the count value is sent to an indicator with a data type of U32 (32-bit integers), this code would produce a 40 MHz, 32-bit counter on the FPGA chip. You could copy and paste this several times to get multiple counters, all functioning on different digital lines completely parallel to one another. The real value with using intelligent DAQ, however, is in the customization of counter operations. You can choose to increment the counter every three rising edges, or even trigger an analog acquisition based on the count register value. Many complex counter operations, such as finite pulse train generation or cascaded event counting require the use of two counters, which usually means all onboard counters for typical multifunction devices. With up to 160 digital lines, the maximum number of counters on intelligent DAQ hardware is rarely limited by I/O availability and is usually determined by the size of the FPGA chip. Becasue the LabVIEW code is running in silicon, there’s no need to “arm” or “rearm” general-purpose counters, and you get full control over counter operation.
Figure 13 (below) is an example of using counters to generate a continuous pulse train with a pause trigger in NI-DAQmx.
In LabVIEW FPGA, the pause trigger needs no configuration, because a simple case structure will implement the same functionality in silicon. Here’s what the same functionality looks like when implemented with intelligent DAQ (figure 14).

[+] Enlarge Image
Figure 14. Continuous Pulse Train Generation and Pause Trigger with Intelligent DAQ
In this case, digital I/O line 0 is the pause trigger, and the pulse will output on digital I/O line 1. The single-cycle timed loop is used to get 25 ns resolution on each pulse, because that will be the value of a single tick using the 40 MHz timing source.
See Also:
PWM Output with the LabVIEW FPGA Module
Digital I/O Applications
With up to 160 hardware-timed digital lines, there are many possible digital applications with intelligent DAQ hardware. We’ve already discussed using digital I/O for triggering, synchronization, and counter/timer implementations, but intelligent DAQ can also be used for bit-error-rate testing, digital pattern matching, pulse width modulation, quadrature encoders, and digital communication protocols. Both custom and standard serial interfaces can be programmed directly from the digital timing diagrams. SPI, for example, is very a common serial protocol for communicating with hardware components such as microcontrollers and ADCs. Figure 15 (below) is the timing diagram that shows the three digital lines required for 16-bit SPI communications.

Figure 15. SPI Communication Input Timing Diagram
As shown by the timing diagram, each of the 16 bits of data is passed serially on every clock cycle while the chip select line is low. Now let’s look at how this would be programmed in LabVIEW FPGA using three digital lines on intelligent DAQ hardware.
The outer while loop in Figure 16 ensures that all code will execute continuously, and the write Boolean control starts the data transfer using the case structure . The first frame of the sequence structure sets the chip select line to be low and then the middle frame writes a data bit and toggles the clock line 16 times. Finally, the third sequence frame sets the chip select line back to true and resets the data line to its default state of false. This simple example illustrates only one of the many possibilities for digital communication with intelligent DAQ. If you wanted to implement digital handshaking, it would require two channels for the ACK (ready) and REQ (pause) lines, one for the clock signal and data lines working in parallel.
Digital lines can often bounce, especially when using electromechanical contacts, but there are several ways to add a debounce filter on digital input lines with LabVIEW FPGA. A digital debounce filter removes false changes of state by ensuring that transitions maintain their value for a minimum duration, thereby avoiding erroneous readings that result from bouncing. Figure 17 is an example of how this could be done with intelligent DAQ.

[+] Enlarge Image
Figure 17. Block Diagram of Digital Filter on Intelligent DAQ Hardware
See Also:
SPI Communication in LabVIEW FPGA
I2C Implementation in LabVIEW FPGA
Developing a SPDIF Input Module in LabVIEW FPGA
RS-232 Interface Using the LabVIEW FPGA module
Data Transfer Methods
A major difference between traditional multifunction DAQ with the NI-DAQmx driver and intelligent DAQ is way that data transfer is implemented. The NI-DAQmx driver will abstract out all transfers from the device to the host computer, while this must be completely programmed in LabVIEW for all FPGA-based hardware. There are several ways of buffering data onboard the device, and using different data transfer methods such as DMA channels and interrupt requests.
A FIFO buffer in LabVIEW FPGA is configured in the LabVIEW project explorer, and can be implemented using either onboard memory or hardware logic. Figure 18 shows how to configure a FIFO buffer of integer numbers in onboard block memory from the project explorer.
Once the FIFO is created, it can be used to transfer data between multiple loops on a LabVIEW FPGA block diagram. The example in Figure 19 shows data being written to the FIFO in the loop on the left, and then data being read from the FIFO in the loop on the right.
Direct Memory Access (DMA) channels, which are also implemented using LabVIEW FPGA FIFOs, are configured similarly in the project explorer.

[+] Enlarge Image
Figure 20. DMA FIFO Configuration in LabVIEW FPGA

Figure 21. LabVIEW FPGA Block Diagram with DMA FIFO and Bit Packing
All DMA FIFO transfers are 32 bits, so when passing data from a 16-bit analog input channel, it’s often more efficient to combine samples and pass data two channels, or samples, at a time. This is known as bit-packing, and shown in Figure 21. When data is passed directly to the host PC memory, it can then be read using the host interface functions on LabVIEW running in the Windows environment (Figure 22).
As shown in Figure 22, the host interface block diagram references the FPGA target VI and then continuously reads the DMA FIFO in a while loop. The 32-bit data is split into the two 16-bit channels that were sampled and plotted on a waveform chart. The host interface VI can also read and write to any front panel indicator or control on the FPGA VI, and in this case the stop button control is being written to as well.
See Also:
Using DMA FIFO to Develop High-Speed Data Acquisition Applications for Reconfigurable I/O Devices
Conclusion
While fixed ASICs such as the DAQ-STC2 will meet the majority of data acquisition requirements, complete flexibility and customization can be achieved only with the reconfigurable, FPGA-based I/O timing and control of intelligent DAQ. With LabVIEW FPGA, triggering and synchronization tasks become as simple as graphically drawing the block diagram to do exactly what you need; and with independent analog and digital I/O lines, intelligent DAQ can take advantage of the true parallelism that FPGAs offer. Whether it is multirate sampling, custom counter operation, or onboard decision making at 40 MHz, R Series intelligent DAQ devices have revolutionized the possibilities for multifunction data acquisition.
Related Links:
What can I do with LabVIEW FPGA?
LabVIEW FPGA Interactive Tutorial
R Series Intelligent DAQ FAQ
Intelligent DAQ – Webcast On Demand
FPGA-Based Control Frequently Asked Questions
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
















