Main Content

Acquire Data from Multiple Channels using an MCC Device

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)');