Main Content

Acquire Data with Analog Input Recorder

This topic shows how to use the Analog Input Recorder app to view and record data from an NI USB-6211 device.

To open the Analog Input Recorder, on the MATLAB® Toolstrip, on the Apps tab, in the Test and Measurement section, click Analog Input Recorder.

Analog Input Recorder button

Upon opening, the Analog Input Recorder attempts to find all your attached analog and audio input devices.

Note

Opening the Analog Input Recorder deletes all your existing DataAcquisition interfaces in MATLAB.

The DataAcquisition interface created by the Analog Input Recorder is not accessible from the MATLAB command line.

If you plug in a device while the app is open, you must refresh the listing for access to that device. On the Devices tab, click Refresh. Use the same procedure to remove a device from the listing after unplugging it.

Select the device you want to use in the Device List. The app immediately starts a preview of the analog input using default settings.

Analog Input Recorder app

Modify any scan and channel settings for your specific needs. The following image shows the app displaying three channels of the device. Notice that the Max Rate value has changed with the number of channels; this relationship depends on the device.

Analog Input Recorder app with three channels

Set values for Number of Scans or Duration, and Rate.

Check Continuous if you want to override the duration or number of scans. In this mode, recording continues until you explicitly stop it.

When you are ready to start recording data, click Record.

When recording is complete, either because the specified number of scans is recorded or you click Stop, the recorded data is assigned to the indicated MATLAB Workspace variable. By default, the variable starts as DAQ_1, and its name is incremented with every recording, but you can specify any valid MATLAB variable name not already in use. The variable is assigned an M-by-N timetable, where M table rows is the number of scans and N columns is the number of channels.

The following commands show the beginning of the acquired timetable for a multiple channel recording.

whos
  Name          Size            Bytes  Class        Attributes

  DAQ_1      1000x3             33315  timetable

View the first four rows of the timetable.

DAQ_1(1:4,:)
ans =
  4×3 timetable

      Time       Dev1_ai0    Dev1_ai1    Dev1_ai2
    _________    ________    ________    ________

    0 sec          4.0578    -1.9676      5.1516 
    0.001 sec      2.8081    -2.5671      4.3738 
    0.002 sec      1.4604    -3.0992      3.4339 
    0.003 sec    0.029896    -3.5211      2.3651 

The timestamp elements of the table are relative to the first scan. The absolute time of the first scan is available in the timetable TriggerTime custom property. For example,

DAQ_1.Properties.CustomProperties.TriggerTime
  datetime

   19-Nov-2019 15:21:01.239

In the Analog Input Recorder, click Generate Script for the app to open the MATLAB editor and display the equivalent code for recording data. The following code is generated for the finite (non-continuous) 3-channel recording of this example.

Analog Input Recorder generated code

See Also

Apps

Related Topics