putdata

Queue analog output data in engine for eventual output

Syntax

putdata(obj,data)

Arguments

obj

An analog output object.

data

The data to be queued in the engine.

Description

putdata(obj,data) queues the data specified by data in the engine for eventual output to the analog output subsystem. data must consist of a column of data for each channel contained by obj. That is, data must be an m-by-n matrix, where m rows correspond to the number of samples and n columns correspond to the number of channels in obj.

data can consist of doubles or native data types but cannot contain NaNs. data must contain a column of data for each channel contained in obj. If data contains any data points that are not within the UnitsRange of the channel it pertains to, the data points will be clipped to the bounds of the UnitsRange property.

data can be a tscollection object or timeseries object. If data is a tscollection object, there must be one timeseries per channel in obj. If data is a timeseries object, there must be only one channel in obj. If the tscollection or timeseries object contains gaps, or is sampled at a different rate than the SampleRate of obj, the data will be resampled at the rate of obj using a zero order hold.

For more information on using the Time Series functionality, see Example: Time Series Objects and Methods in the MATLAB documentation.

Examples

Create the analog output object ao for a National Instruments® board, add two output channels to it, and generate 10 seconds of data to be output.

ao = analogoutput('nidaq','Dev1');
ch = addchannel(ao,0:1);
ao.SampleRate = 1000
data = linspace(0,1,10000)';

Before you can output data, it must be queued in the engine using putdata.

putdata(ao,[data data])
start(ao)

More About

expand all

Tips

More About Queuing Data

  • Data must be queued in the engine before obj is executed.

  • putdata is a blocking function because it returns execution control to the MATLAB workspace only when the requested number of samples is queued in the engine for each channel group member.

  • If the value of the RepeatOutput property is greater than 0, then all queued data is automatically requeued until the RepeatOutput value is reached. RepeatOutput must be configured before start is issued.

  • After obj executes, you can continue to queue data unless RepeatOutput is greater than 0.

  • Due to buffering constraints on certain devices, additional data queued close to the termination of the previous data may not be output to the device. To insure that all data is output, queue additional data well before the device has output all data.

  • You can queue data in the engine until the value specified by the MaxSamplesQueued property is reached, or the limitations of your hardware or computer are reached.

  • You should not modify the BitsPerSample, InputRange, SensorRange, and UnitsRange properties after calling putdata. If these properties are modified, all data is deleted from the data acquisition engine. If you add a channel after calling putdata, all data will be deleted from the buffer.

  • The timeseries object must contain a single column of data.

More About Outputting Data

  • Data is output as soon as a trigger occurs.

  • An error is returned if a NaN is included in the data stream.

  • You can specify data as the native data type of the hardware.

  • If the output data is not within the range specified by the OutputRange property, then the data is clipped.

  • The SamplesOutput property keeps a running count of the total number of samples that have been output per channel.

  • The SamplesAvailable property tells you how many samples are ready to be output from the engine per channel. After data is output, SamplesAvailable is automatically reduced by the number of samples sent to the hardware.

Was this topic helpful?