How to improve the time cost of 'putvalue' in DAQ toolbox

1 visualización (últimos 30 días)
Alberich Qi
Alberich Qi el 23 de En. de 2012
Editada: Thomas Carpenter el 7 de Oct. de 2013
I am using NI DAQ card USB6008 for data input and output, and the 'putvalue' and 'getvalue' commond in DAQ toolbox cost 4~5 milliseconds in average. However, in my experiment, a commond time cost below 1 ms is prefered.
How can I improve it?
I have considered using C++ in matlab, but 'create task' and 'start task' is needed every time when we call the C function, thus it still cost 2~3 ms.
Create a task using C++ in the beggining and keep it alive in the whole matlab process might be a possible idea, but the memory address of the task is always deleted automatically when the c function completes, and I don't know how to solve this problem.
Do anyone have any idea ?
Thanks!

Respuestas (3)

Manisha
Manisha el 31 de En. de 2012
Hi Alberich,
Have you tried the Session-based interface? 4-5 ms sounds reasonable. Could you explain why you need it to be below 1 ms.
Another thing you could try is the direct driver access provided by the Data Acquisition Toolbox ( introduced with Session-based interface ) to get minimum time cost for these operation using the same task handle. See this fileexhange for an example on how to use that interface.
Your code could look something like this:
% Create the Task
[status,taskHandle] = daq.ni.NIDAQmx.DAQmxCreateTask (char(0),uint64(0));
[status] = daq.ni.NIDAQmx.DAQmxCreateAIVoltageChan (...
taskHandle,... % The task handle
'Dev1/ai0',... % physicalChannel
char(0),... % nameToAssignToChannel
niTerminalConfig,... % terminalConfig
range.Min,... % minVal
range.Max,... % maxVal
daq.ni.NIDAQmx.DAQmx_Val_Volts,... % units
char(0)); % customScaleName
..More code to read the channel and destroy at the end
This way you can use the same task handle again without needing to recreate it.
Hope that helps,
Manisha

Walter Roberson
Walter Roberson el 31 de En. de 2012
Which release are you using? If you are using R14SP2 through R2006A, then please see http://www.mathworks.com/support/solutions/en/data/1-2KRVG0/index.html?solution=1-2KRVG0

Alberich Qi
Alberich Qi el 15 de Feb. de 2012
Thanks very much, it is really the way I want. However, I find that it does not support digital I/O from the information in this page http://www.mathworks.co.jp/help/toolbox/daq/bsvjl59-1.html Is there any way to apply it on digital I/O?
The reason I need it to be below 1ms : I want to produce a animation in my experiment. I have to output a rising-edge as a sign of each frame, then show the frame immediately after the sign, and then generate the next frame. The output and other process (show frame and generate the next frame) has to be complete in 16ms (1 frame). As a sign of the frame, we need an accuracy about 1ms. However, the time lag it not fixed, and the variation is about 2~3ms. This is unacceptable for a sign. Also, generating frame need some time, thus this process won't be completed if the NI output takes much time.

Categorías

Más información sobre Data Acquisition Toolbox Supported Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by