acquire data from multiple channels using an mcc device -pg电子麻将胡了
this example shows how to acquire data from multiple analog input channels with an mcc device.
hardware setup
this example uses a measurement computing usb-1608fs-plus device to log data from analog input channels 0 and 9, which are connected to the outputs of a function generator.
display a list of available devices
discover devices connected to your system using daqlist.
d = daqlist("mcc")
d =
1×4 table
deviceid description model deviceinfo
________ _____________________________________________ _________________ ________________________
"board0" "measurement computing corp. usb-1608fs-plus" "usb-1608fs-plus" [1×1 daq.sdk.deviceinfo]
get details about a device
the daqlist function shows you the overview of devices available. you can find additional device details by reviewing the deviceinfo field of the table.
deviceinfo = d{1, "deviceinfo"}
deviceinfo =
mcc: measurement computing corp. usb-1608fs-plus (device id: 'board0')
analog input supports:
4 ranges supported
rates from 0.1 to 100000.0 scans/sec
8 channels ('ai0' - 'ai7')
'voltage' measurement type
create a dataacquisition and add input channels
the daq function creates a dataacquisition object. the dataacquisition contains information describing hardware, scan rate, and other properties associated with the acquisition.
dq = daq("mcc") % the |addinput| function adds an analog input channel to % the dataacquisition. you can add more than one channel to a % dataacquisition. ch1 = addinput(dq, "board0", 0, "voltage"); ch2 = addinput(dq, "board0", 1, "voltage");
dq =
dataacquisition using measurement computing corp. hardware:
running: 0
rate: 1000
numscansavailable: 0
numscansacquired: 0
numscansqueued: 0
numscansoutputbyhardware: 0
ratelimit: []
show channels
show properties and methods
acquire timestamped data
the read function starts the acquisition and returns the results as a timetable.
data = read(dq, seconds(1));
plot acquired data
plot(data.time, data.board0_ai0, data.time, data.board0_ai1); xlabel('time (s)'); ylabel('voltage (v)');

change default properties of the acquisition
by default, acquisitions run for one second at 1000 scans per second. to acquire at a different rate, change the rate property.
dq.rate = 10000; [data, starttime] = read(dq, seconds(1)); plot(data.time, data.board0_ai0, data.time, data.board0_ai1); xlabel('time (s)'); ylabel('voltage (v)');
