This topic shows how to use the Analog Input Recorder app to view and record data from an NI USB-6218 device.
To open the Analog Input Recorder, on the MATLAB® Toolstrip, on the Apps tab, in the Test and Measurement section, click the Analog Input Recorder.
Upon opening, the Analog Input Recorder attempts to find all your attached analog and audio input devices.
Opening the Analog Input Recorder deletes all your existing data acquisition sessions in MATLAB.
The data acquisition session 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 the 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.
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.
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 will continue 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 scan is recorded or you click Stop, the logged 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. The variable is assigned an M-by-N timetable, where M is the number of scans and N is the number of channels.
The following commands show the beginning of the acquired timetable for a multiple channel recording.
Name Size Bytes Class Attributes DAQ_4 1000x3 33315 timetable
View the first four rows of the timetable.
ans = 4×3 timetable Time ai0 ai1 ai2 _________ _______ ________ _______ 0 sec 0.59036 1.1226 1.6268 0.001 sec -1.0661 -0.49113 0.07001 0.002 sec -2.6327 -2.0683 -1.4901 0.003 sec -4.0592 -3.5349 -2.9738
The timestamp elements of the table are relative to the first scan. The absolute time of
the first scan is available in the timetable
UserData property. For
In the Analog Input Recorder, click Generate Script for the app to
open the MATLAB editor and display the code for recording data. The following code is
generated for the finite (non-continuous) 3-channel recording of this example. Notice that
this code uses the
startForeground function; a continuous recording