Accelerating the pace of engineering and science

Data Acquisition Toolbox

Key Features

  • Support for a variety of industry-standard data acquisition boards and USB modules
  • Support for analog input, analog output, counters, timers, and digital I/O
  • Direct access to voltage, current, IEPE accelerometer, and thermocouple measurements
  • Live acquisition of measured data directly into MATLAB
  • Hardware and software triggers for control of data acquisition
  • Device-independent software interface
Using Data Acquisition Toolbox to acquire an input signal from a data acquisition board directly into MATLAB

Using Data Acquisition Toolbox to acquire an input signal from a data acquisition board directly into MATLAB. The acquired data is displayed simultaneously as a time-domain signal, an instantaneous FFT, and a waterfall plot, making use of MATLAB signal processing and visualization capabilities.

Supported Hardware Devices and Vendors

Data Acquisition Toolbox supports PC-compatible data acquisition hardware from multiple vendors, including National Instruments, Digilent, and Analog Devices. The toolbox also supports Microsoft® Windows® compatible sound cards. See more information on supported hardware.

If you work with a variety of hardware, the toolbox provides common base properties that apply to all supported hardware, such as sample rate, trigger settings, and channel properties. Using these properties promotes code reuse and reduces the need to change code when you change hardware. The toolbox also enables you to access device-specific features of your hardware from MATLAB.

Making Measurements with DAQ Hardware

Data Acquisition Toolbox lets you make a variety of measurements directly from MATLAB without the need to convert the data. Most data acquisition hardware provides the general capability to convert analog voltage data to a digital signal that a computer can process. Some data acquisition hardware has additional capabilities that allow for collecting and processing data directly from thermocouples, RTD devices, IEPE accelerometers and microphones, current-based sensors, or bridge-based sensors. To facilitate making measurements directly from MATLAB, Data Acquisition Toolbox supports the following measurement types:

Voltage — Data from general purpose A/D cards and sound card recording devices

Current — Data from current-based sensors, such as 4-20 mA sensors commonly used for process control

IEPE accelerometer — Data from IEPE accelerometers that need a constant excitation current source on the same wire on which you measure the acceleration

IEPE microphone — Data from IEPE microphones that need a constant excitation current source on the same wire on which you measure the sound pressure

Thermocouple and RTD — Data measured in degrees Celsius, Fahrenheit, or Kelvin

Bridge-based sensor — Data from resistive sensors, such as strain gauges in a variety of bridge configurations that require an excitation voltage

Accessing Subsystems of a DAQ Device

The toolbox provides functions to access four subsystems commonly found on DAQ hardware: analog input, analog output, digital I/O, and counter/timer.

Setup for a data acquisition and analysis session using the legacy interface

Data Acquisition Toolbox enables MATLAB to interface with the data acquisition hardware, including USB DAQ devices, PCI/PCIe DAQ cards, DAQ modules in a CompactDAQ chassis, and sound cards.

You can use Data Acquisition Toolbox to access the subsystems of your DAQ hardware from National Instruments and other vendors and perform a wide variety of measurements such as voltage, current, temperature, IEPE accelerometer, and bridge measurements.

Sample code that uses the session-based interface.

Data Acquisition Toolbox enables MATLAB to discover and interface with data acquisition devices such as the NI 9205 CompactDAQ module.

You can create session objects to provide a gateway to the hardware's functionality and to control the behavior of your acquisition. By adding channels or lines to your session object, you can synchronize your data collection. The toolbox supports an unlimited number of channels or lines, enabling you to use as many as your hardware permits.

Analog Input

Analog input functions let you acquire signals from your hardware. You can create a session object, add analog input channels to the object, acquire data to memory, read data into the workspace, and preview the most recently acquired data.

Analog Output

Analog output functions let you send signals out from your hardware. You can create a session object, add analog output channels to the object, queue data sets for output, and generate analog signals.

Digital I/O

Digital I/O functions enable you to generate or read digital signals using your hardware. You can create a session object, add digital I/O lines to the object, send data to the hardware, and read data into the workspace. The toolbox supports clocked digital I/O.

Counter/Timer

Counter/timer functions let you access counters on data acquisition hardware. You can configure counters as input or output channels. Counters configured as inputs can count events and measure frequency, pulse width, and position. Counters configured as outputs can generate pulse trains.

MATLAB code used to acquire data from a DAQ device with counter/timer channels

MATLAB code used to acquire data from a DAQ device with counter/timer channels.

Audio Input and Output

Audio input and audio output functions let you acquire and generate signals using built-in or external sound cards. You can create a session object, add multiple audio input or output channels to the object, acquire data to memory, read data into the workspace, and preview the most recently acquired audio data.

Controlling Your Acquisition

Data Acquisition Toolbox supports a wide range of functions for controlling your acquisition. For example, you can set event information, evaluate acquisition status, define triggers and callbacks, preview data while a device is running, and perform analysis on the fly. The toolbox also supports several hardware-specific properties that can be displayed and customized to your specifications.

Managing Data

The toolbox provides functions for previewing and extracting data for analysis. It streams data into MATLAB or Simulink in double-precision floating-point format, enabling you to work with the data just as you would with any other matrix in MATLAB or Simulink. You can also use a native hardware format to stream in data.

Logging Data

Data Acquisition Toolbox provides functions for logging data to disk, memory, or both, while an analog input object is running. You can log data, events, and errors. In addition, the toolbox provides functions for extracting data from log files it has generated.

Simultaneous Collection and Analysis of Data

Most data acquisition tasks are initiated by events. An event occurs at a specific time after a condition has been met. Event types supported by Data Acquisition Toolbox include:

  • Start and stop
  • Number of samples acquired
  • Errors
  • Triggers
  • Number of output samples

Events may result in one or more callbacks. In MATLAB, these event types execute a MATLAB function that you specify.

Data Acquisition Toolbox provides functions for both foreground and background data acquisition. Foreground data acquisition blocks the MATLAB command line; background acquisition does not. Background acquisition enables you to collect data continuously and plot or process the data while you are collecting it. A listener is available to flag session events. When an event occurs, the specified callback function is executed.

Handling Errors

Data Acquisition Toolbox provides a consistent set of error and warning messages. If a hardware error message is not handled by the toolbox in MATLAB or Simulink, an external error is reported with the vendor-specific hardware error message.

Evaluating Your Acquisition

Data Acquisition Toolbox lets you evaluate the status of an acquisition and the available data acquisition resources, including installed hardware, hardware drivers, and adapters. You can display the following types of information:

  • Device object and channel status
  • Session object status
  • Hardware information
  • Data acquisition engine information
Script illustrating the four steps of a typical MATLAB data acquisition session: creation, configuration, acquisition, and clean-up.

Script illustrating the four steps of a typical MATLAB data acquisition session: creation, configuration, acquisition, and clean-up. A few lines of code let you acquire two seconds of data from a data acquisition device, process the acquired data, and visualize the results.

Hands-on Learning with MATLAB and Analog Discovery

View webinar