How to improve the time cost of 'putvalue' in DAQ toolbox
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (3)
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
0 comentarios
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
Ver también
Categorías
Más información sobre Data Acquisition Toolbox Supported Hardware en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!