Getting Started with MCC Devices
This example shows how to get started with MCC devices from the command line.
Discover Available Devices
Discover devices connected to your system using daqlist
. To learn more about an individual device, access the entry in the device table.
d = daqlist("mcc");
d(1, :)
ans = 1×4 table DeviceID Description Model DeviceInfo ________ _____________________________________________ _________________ ________________________ "Board0" "Measurement Computing Corp. USB-1608FS-Plus" "USB-1608FS-Plus" [1×1 daq.sdk.DeviceInfo]
Create a DataAcquisition
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")
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
Add an Analog Input Channel
The addinput
function attaches an input channel to the DataAcquisition. You can add more than one channel to a DataAcquisition. This example uses one input channel, Ai0, which is connected to a function generator channel outputting a 10 Hz sine wave.
addinput(dq, "Board0", "Ai0", "Voltage"); dq
dq = DataAcquisition using Measurement Computing Corp. hardware: Running: 0 Rate: 1000 NumScansAvailable: 0 NumScansAcquired: 0 NumScansQueued: 0 NumScansOutputByHardware: 0 RateLimit: [0.1000 100000] Show channels Show properties and methods
Acquire Timestamped Data
The read
function starts the acquisition and returns the results as a timetable.
[data, startTime] = read(dq, seconds(1));
Plot Acquired Data
plot(data.Time, data.Board0_Ai0); 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 = 5000;
Run the acquisition and plot the acquired data:
[data, startTime] = read(dq, seconds(1)); plot(data.Time, data.Board0_Ai0); xlabel("Time (s)"); ylabel("Voltage (V)");