Main Content

Acquire Data in Foreground

This example shows how to acquire voltage data from an NI 9205 device with ID cDAQ1Mod1.

Create a DataAcquisition object and save it to the variable d.

d = daq("ni")
d = 

DataAcquisition using National Instruments(TM) hardware:

                     Running: 0
                        Rate: 1000
           NumScansAvailable: 0
            NumScansAcquired: 0
              NumScansQueued: 0
    NumScansOutputByHardware: 0
                   RateLimit: []

By default, the acquisition is configured to acquire at the rate of 1000 scans per second.

Add an analog input channel for voltage measurement using the device channel ID ai0.

addinput(d,"cDAQ1Mod1","ai0","Voltage");

Acquire data for two seconds, store it in the variable data, and plot it.

data = read(d,seconds(2),OutputFormat="Matrix");
plot(data)

Specify number of scans to acquire data as 4096. Changing the acquired number of scans changes the duration of the acquisition to 4.096 seconds as the default rate is 1000 scans per second.

Acquire the data, store it in the variable data, and plot it.

data = read(d,4096,OutputFormat="Matrix");
plot(data)

See Also

Functions

Topics