Acquire Data in the 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
ai0
:
addinput(d,"cDAQ1Mod1","ai0","Voltage");
Acquire data for 2 seconds and store it in the variable, data
,
then plot it:
data = read(d,seconds(2),"OutputFormat","Matrix"); plot(data)
Specify an acquisition of 4096 scans of data. Changing the number of scans changes the duration of the acquisition to 4.096 seconds at the default rate of 1000 scans per second.
Acquire the data and store it in the variable data
, and then
plot it:
data = read(d,4096,"OutputFormat","Matrix"); plot(data)