Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Generate Signals in the Foreground

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

Create a session object and save it to the variable, s:

s = daq.createSession('ni');

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

s.Rate = 10000

s = 

Data acquisition session using National Instruments hardware:
   Will run for 1 second (10000 scans) at 10000 scans/second.
   Operation starts immediately.
      No channels have been added.   

Add an analog output 'Voltage' channel:

addAnalogOutputChannel(s,'cDAQ1Mod2',0,'Voltage')

ans = 

Data acquisition session using National Instruments hardware:
   No data queued.  Will run at 1000 scans/second.      Number of channels: 1
      index Type  Device   Channel MeasurementType      Range       Name
      ----- ---- --------- ------- --------------- ---------------- ----
      1     ao   cDAQ1Mod2 ao0     Voltage         -10 to +10 Volts

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

Create the data to output:

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

Queue the data:

queueOutputData(s,outputData);

The duration changes to 0.22 seconds based on the length of the queued data and the specified scan rate. When the session contains output channels, duration and number of scans become read-only properties of the session. The number of scans in a session is determined by the amount of data queued and the duration is determined by s.ScansQueueds.Rate.

Display the session object to see this change:

s

s = 

Data acquisition session using National Instruments hardware:
   Will run for 2200 scans (0.22 seconds) at 10000 scans/second.
   .All devices synchronized using cDAQ1 CompactDAQ chassis backplane. (Details)
      Number of channels: 1
      index Type  Device   Channel MeasurementType Range            Name
      ----- ---- --------- ------- --------------- ---------------- ----
      1     ao   cDAQ1Mod2 ao0     Voltage (Diff)  -10 to +10 Volts

Generate the data. MATLAB® returns once the generation is complete.

startForeground(s);

Related Topics

Was this topic helpful?