How to improve the time cost of 'putvalue' in DAQ toolbox
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (3개)
Manisha
2012년 1월 31일
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
Walter Roberson
2012년 1월 31일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!