Generate Signals in the Foreground

This example shows how to generate data using an NI 9263 device with ID cDAQ1Mod2.

Create a DataAcquisition object assigned to the variable d:

d = daq("ni");

Change the scan rate of the DataAcquisition to generate 10,000 scans per second:

d.Rate = 10000
d = 

DataAcquisition using National Instruments(TM) hardware:

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

Add an analog output Voltage channel:

ch = addoutput(d,"cDAQ1Mod2",0,"Voltage");

You can specify the channel ID on NI devices using a terminal name, like 'ao1', or a numeric equivalent like 1.

Create the data to define the output signal being generated. The output scans of one channel are defined by a column vector.

outputData = linspace(-1, 1, 2200)';

Generate the output signal. The output signal will have a duration of 0.22 seconds, based on the length of the queued data and the specified scan rate. MATLAB® waits for this foreground generation, and returns when the generation is complete.


Related Topics