Programming Data Acquisition for Linux with NI-DAQmx Base
Overview
This document is part of the Advanced Data Acquisition Series, consisting of tutorials and interactive presentations on how you can use NI LabVIEW, NI-DAQ software, and National Instruments hardware to easily create advanced DAQ applications. To view a comprehensive list of available advanced DAQ topics, please visit the Data Acquisition with LabVIEW site.
Table of Contents
Installation of NI-DAQmx Base for Linux
For a comprehensive explanation of driver installation, supported platforms, supported hardware and known issues, please refer to the most recent version of the respective readme file. General Installation Instructions for NI-DAQmx and NI-DAQmx Base:
- Login to your Linux shell as root
- Create a temporary folder on your local hard drive
- Download the image of the latest version of NI-DAQmx for Linux or NI-DAQmx Base for Linux
- Create a CD using the downloaded image or mount the image on your system
- Install your hardware first before installing the driver software
- Run “./INSTALL” from the CD or the mount created in step 4. The installer will:
- Prompt you to read and respond to the terms of the NI software license
- Automatically build and install the driver software kernel module
- Install shared tools for device detection and configuration
- Install LabVIEW and/or C API support
Task Configuration using NI-DAQmx and NI-DAQmx Base for Linux
There are three ways to configure tasks in NI-DAQmx Base.
The first method, which is preferred, involves dynamically creating the task using DAQmx Base Create Task VI followed by the DAQmx Base Create Virtual Channel VI. The second and third methods both use the NI-DAQmx Base Configuration Utility; the difference between the second and third method is how the utility is launched and used.
To use the second method, launch the NI-DAQmx Base Task Configuration Utility from the Tools menu in LabVIEW. Launching the utility from the Tools menu in LabVIEW includes any other tasks that may be in memory in LabVIEW at the time the utility is launched. Any changes made with the LabVIEW launched utility immediately takes effect in LabVIEW and on any C program launched after the utility is exited.
The third method involves running 'mxbaseconfig' from the command line. The 'mxbaseconfig' command opens the NI-DAQmx Base Task Configuration Utility. The utility saves its data to the same configuration file as the LabVIEW launched version, but changes made with this version are only be seen in LabVIEW if LabVIEW is restarted.
The following example demonstrates a temperature measurement application designed using LabVIEW and the NI-DAQmx Base.

[+] Enlarge Image
Figure 6: The logic used to acquire data is the same as with NI-DAQmx.
Click on the icon below to see full size of figure 6
- Create empty task using DAQmxBase Create Task.vi
- Create a Thermocouple (TC) temperature measurement channel using DAQmxBase Create Virtual Channel.vi.
- Specify the hardware timing parameters using DAQmxBase Timing.vi
- Start the acquisition using DAQmxBase Start Task.vi
- Read N samples using DAQmxBase Read.vi and Plot it. By default, the Read VI reads all available samples, but you can specify how many samples to read at a time and the timeout value. Continue reading data until the stop button is pressed or an error occurs.
- Stop the task using DAQmxBase Step Task.vi
- Clear the Task using DAQmxBase Clear Task.vi
- Use the popup dialog box to display an error if any.
Programming data acquisition with NI-DAQmx Base for Linux is analogous to NI-DAQmx. The NI-DAQmx Base VIs have all the same input and output terminals. The user can open each VI and tunnel down to the lowest level which leads to the RLP node. These RLP nodes call into chip objects for the hardware used. These RLP nodes are closed source. If personal modifications happen to break the driver, National Instruments recommends reinstalling the driver as it is not possible to support personal modifications.
Example Programs and Documentation
The NI-DAQmx Base installer includes example programs designed to demonstrate the correct use of the API for each measurement type.
LabVIEW Examples for LabVIEW are located in <LabVIEW>/examples/daqmxbase and are not indexed in the NI Example Finder.
C examples are installed by default to /usr/local/natinst/nidaqmxbase/examples. The make files create the links to the necessary libraries. Run the device configuration utility (lsdaq) before running the examples. An example that is shipped with NI-DAQmx Base is 'Acquire N Scans'. To compile and run this example:
- cd /usr/local/natinst/nidaqmxbase/examples/ai
- make
- ./acquireNScans
LabVIEW help files are accessible from the LabVIEW Help menu.
Documentation is located in /usr/local/natinst/nidaqmxbase/documentation and includes the NI-DAQmx Base C Function Reference, the hardware references, and supporting PDFs.
For more information, please refer to the readme file available for download along with NI-DAQmx Base for Linux.
Related Links:
National Instruments Products Supported on Linux
Frequently Asked Questions About NI-DAQmx for Linux
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/).

