MCC DAQ 231: pushing output to DAC very slow

2 visualizaciones (últimos 30 días)
Manikanta Kotaru
Manikanta Kotaru el 13 de Jul. de 2017
Respondida: Walter Roberson el 13 de Jul. de 2017
I currently use following matlab script (attached inline below) to send data to DAC of MCC DAQ USB 231. However it takes 0.25 seconds for outputting each unique output value (which is extremely slow for our purposes). However, we want to do push output to DAC every few milliseconds.
Is there MATLAB script or any other script to achieve 'pushing DAC output every few milliseconds'.
s=daq.createSession('mcc');
addAnalogOutputChannel(s,'Board0',[0 1],'Voltage');
s.Rate = 1000;
volInValues =[0 0.1 -0.1];
tic
for iStep=1:length(volInValues)
dataTmp = volInValues(iStep)*ones(1,51);
data = [dataTmp(:) dataTmp(:)];
s.queueOutputData(data);
s.startForeground();
% pause(1)
end
toc

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Jul. de 2017
s.startForeground should be reserved for cases where you have filled the queue with multiple values and you want to start sending the data; it is not intended to indicate sample by sample transfer.
If you were in a situation where you only wanted to queue a limited number of samples, perhaps because you wanted to be able to have the output react to earlier samples, then you should configure NotifyWhenScansQueuedBelow and add a listener on DataRequired; see https://www.mathworks.com/help/daq/ref/notifywhenscansqueuedbelow.html
If you are in a situation where you do not want to queue at all, just send one sample at a time, then do not queue the data or start the foreground: use outputSingleScan()
Single Scan output appears to be more closely associated with analog channels being handled deliberately asynchronously ("send the data whenever we feel like it"), but I also see it used sometimes for sending single samples on a digital channel when the digital channel is acting as a strobe. If you just want to send a stream of data, then queue all of the data and start the foreground.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by