| Data Acquisition Toolbox | Search  Help Desk |
Setting the Out-of-Data Value
When data has finished being output to a channel, you can choose the setting of the D/A hardware with theOutOfDataMode property. If OutOfDataMode is set to Hold, then the last output value is held. This is the default behavior for many analog output devices. If OutOfDataMode is set to Stop, the device is stopped and the value written to the D/A converter is device-dependent. For some devices, the D/A value drifts to zero, while for other devices, the last value is held until it is reset. If OutOfDataMode is set to DefaultValue, the value specified for DefaultChannelValue is output. If supported by the hardware, this value is also held. DefaultChannelValue is a channel property and can be configured on a per-channel basis.
For example, suppose you create the analog output object AO for a National Instruments board and add one channel to it. The code below illustrates how to send a last value of 0.5 volts using DefaultChannelValue after queued data has finished being output.
AO = analogoutput('nidaq', 1);
ch = addchannel(AO, 1);
set(AO, 'SampleRate', 10000);
ActualRate = get(AO, 'SampleRate');
set(AO, 'OutOfDataMode', 'DefaultValue');
set(ch, 'DefaultChannelValue', 0.5);
data = sin(0:(2*pi/ActualRate):2*pi)';
putdata(AO, data);
start(AO)
Note:
OutOfDataMode does not apply to sound cards.