필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Alberich Qi
Alberich Qi 2012년 1월 23일
편집: Thomas Carpenter 2013년 10월 7일
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!

답변 (3개)

Manisha
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

Walter Roberson
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
  댓글 수: 1
Alberich Qi
Alberich Qi 2012년 2월 10일
I use matlab R2007b, so maybe it is not the problem.

댓글을 달려면 로그인하십시오.


Alberich Qi
Alberich Qi 2012년 2월 15일
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.

카테고리

Help CenterFile Exchange에서 Periodic Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by