Getting Started with Data Acquisition
You want to get your first data with LabVIEW or an NI data acquisition (DAQ) device. You have the device and want to know what to do next to get data. You’ve come to the right place.
Where you're at:
- You have an NI DAQ device
- Many USB devices are found here: https://www.ni.com/en-us/shop/hardware/products/multifunction-io-device.html
- Common low-cost starter devices are here: https://www.ni.com/en-us/landing/low-cost-daq.html
- You installed LabVIEW - https://www.ni.com/en-us/support/downloads/software-products/download.labview.html#369643
- You installed the DAQmx driver - https://www.ni.com/en-us/support/downloads/software-products/download.labview.html#369643
Don't fret if you have a device that isn't supported by NI's DAQmx driver. While that driver supports a large family of general-purpose devices, it doesn't support everything. Check your device's manual to see what driver supports it.
Keep in mind this guide is for simple data collection as a first experience gathering data with these tools. There are lots of potential use cases we use these tools for, from a large tester to an advanced control system, from a single thermocouple to thousands of channels. We can't cover all that in one blog - but we will cover how to get started.
I'm going to cover an analog input voltage case, but this same flow applies for most kinds of measurements.
MAX Setup
First, connect your device to your computer (odds are it's a USB device). Then launch NI Measurement and Automation Explorer, or MAX for short. Once MAX is open, you'll want to
1 - Make sure your DAQ card is detected, then configure its alias
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGdvCAG&l=en-US
2 - Test out an acquisition in a test panel
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YGZPCA4&l=en-US
There's lots going on here and we won't take the time to learn about acquisition modes now, so just try the “One Sample On Demand mode”, after selecting your channels. This will acquire up to about 300 samples per second. I say 300 very loosely, because there's a lot of potential factors influencing that number - but what I mean is it will update fast enough for you to see your signal change with your eyes and see variations on the time scale of you touching a voltage source. It probably won't show you a 10 kHz sine wave cleanly - at least not yet.
If you see a signal that responds to stimulus, IT WORKS. We can fine tune all sorts of parameters either here or in LabVIEW. So why spend any more time here if we can spend that time in LabVIEW and be able to use that effort in whatever automated scenario we want? Stop the task and close the test panel before moving on. (Failure to release it will give us errors when we try the next step.)
LabVIEW Examples
Fire up LabVIEW. Open up the Example Finder (Menu >> Help >> Find Examples) or https://www.ni.com/getting-started/labview-basics/examples
Let's start with these examples - but first one warning about examples. They are files on disk and if you modify and save them, you're stuck with your modifications until you reinstall LabVIEW... or get creative and copy them from another computer. So don't save yet!
Once you’ve opened the Example Finder, go to Hardware Input and Output >> DAQmx >> Analog Input

Let’s zero in on these Voltage examples to start.

1 - Start with “Voltage – SW Timed Input.vi”
Software timing is where the computer uses its clock to time and initiate the process of acquiring every sample, every time. It is quick and easy to get going and is supported on every device. But, it lacks many of the capabilities of other acquisition types. This should run like the Test Panel. Feel free to fine tune things like acquisition range here, but don't spend too much on sample rate yet if you're aiming for higher speeds.

If you’re measuring a different type of signal such as current or thermocouple directly, take a peek at the related example. You’ll notice with DAQmx that the configuration and the execution are separate – it may only take a small change in configuration to turn code from a voltage task into a current task.
2 - Next try “Voltage - Continuous Input.vi” or “Voltage - Finite Input.vi”
These will use hardware timing - or a clock onboard the DAQ device to time the acquisition. With the hardware clock timing samples and putting them into buffers, the card can clock samples many times faster (assuming it has this capability - many devices have a limited number of timing engines).
Select between the two based on your needs. Finite Input fetches a known number of samples all at once then returns the data to you. Continuous Input gathers samples continuously, returning them to you a chunk at a time while in a loop. The neat thing about hardware timing is that the samples are acquired at a consistent rate – there isn’t an interruption each time you grab your chunk of data.
Now is when we can crank the sample rate up into the tens of thousands of samples per second. Dial in any triggering or other tweaks you want to get your acquisition working well. For continuous acquisitions, tune your chunk size. About ten reads a second is a good starting rule of thumb.
Next steps
Don't use the DAQ Assistant
Originally made for folks getting started, the DAQ Assistant provides a menu interface similar to MAX’s test panel to help set up your task. It is a super easy way to get started and plenty of guides point to it. But the way it gives you the data isn't very compatible with most of the analysis or logging functions - at least not without finding the right converter functions and guessing their configuration correctly with little feedback. If you don’t know where it is, that’s ok – I won’t show you. The DAQ Assistant uses a different paradigm with LabVIEW code that tends to lead newcomers in the wrong direction.
For a less frustrating experience overall, I recommend you keep working with the DAQ examples rather than getting too distracted with the DAQ Assistant. In days since the DAQ Assistant was made, the DAQ examples have improved fantastically. Working with them gives a much smoother transition to more advanced functionality as you want to expand your code's capabilities. If you want an easy-to-use GUI to tweak your task rapidly and iterate quickly, go use the Test Panels in MAX. Once you’ve figured out what works, come back to LabVIEW and start with code from the examples to make things work consistently every time.
Copy code from the examples
Copy code from the DAQ examples and begin adapting them in your own VI. Check out the other examples that perform functions you would like - say logging to file or displaying a graph with analysis results on the screen. Grab code from several to serve as a springboard your code. Just remember to not save the examples! On the other hand, save your code often!
Run it often and try it as you go.
It's a lot easier to develop code incrementally and test it incrementally than it is to build a masterpiece only to find it takes tons of work or was built on an untested assumption about how something works.
Parting words
Looking for something other than voltage? How about Thermocouple? Bridge measurement? Frequency domain data? Is your use case different in another way? That's fairly normal - such use cases vary widely across industries and applications.
Many folks that just picked up a low-cost data acquisition card without using one before often use it for a bit and find that it's not what they really need. Check our common DAQ pitfalls before too long to make sure you're on the right path.
Do you have an unanswered question? Let us know. We've successfully handled many difficult control and acquisition problems. We can do design consulting to get you pointed in the right direction or offer turn-key test or automation systems.
Good luck and have fun!