필터 지우기
필터 지우기

how to use FIFO memory of DAQ

조회 수: 4 (최근 30일)
MANJUNATH
MANJUNATH 2012년 10월 31일
i have a DAQ which has a capability to store 4095 samples in FIFO , i want to store some data and which comes from a sensor via loop and at the end i want to display the stored data ,
at present i a m using start (ai) and getdata syntax inside the loop which making program to run too slow , i.e. every time i run the loop to change the pixel address i have to trigger(start(ai)) and getdata.
any one any idea ?

채택된 답변

Pedro Villena
Pedro Villena 2012년 10월 31일
편집: Pedro Villena 2012년 11월 9일
The FIFO is automatically managed by the DAQ driver. Where you have the option of:
  • Single Sample Function
  • Multi Sample Function
When you use the multi scan funtion, you have to set:
  • Number of Samples (< FIFO mem)
  • Frequecy Rate
So, you have a vector of samples with scanned every 1/Rate seconds in real-time.
Now, In Data Acquisition Toolbox, you could do that
idChannels = 0; %%for more channels = 0:2;
chRate = 44100; %%rate for all channels [sample/s]
FIFO = 4095; %%FIFO size [samples]
acqTime = FIFO/chRate/length(idChannels); %%acquisition time [s]
ai = analoginput('nidaq', 'Dev1');
addchannel(ai, idChannels);
set(ai,'SampleRate',chRate);
set(ai,'SamplesPerTrigger',FIFO);
% Execute acquisition.
num_iterations = 100;
data = zeros(num_iterations*FIFO);
for i = 1:num_iterations,
start(ai);
wait(ai, 2*acqTime); %%wating time 2*acqTime [s]
data((i-1)*FIFO+1:i*FIFO) = getdata(ai);
end
% Delete the object out of the loop.
delete(ai)
clear ai
plot(data);
When you acquire a sample (block of 1 sample) in a loop, the acquisition is very slow cause the PC hardware interruption is very slow. If you want to have a fast acquisition loop, you could get better performance on a Real-Time Operative System, but you only increase the performance in 20%. If its not enought for you, I recommend you to use a dedicated hardware like micro-controller, DSP or FPGA, to implement your acquisition and control loop.
  댓글 수: 2
MANJUNATH
MANJUNATH 2012년 11월 1일
Thank u Sir,
if samples per trigger is 4095 it will take more time . I have to address the pixels using Digital outputs, so i use "putvalue=dio command"
then i wanna use imshow so that i want to store the data in 32by32 matrix
please help me with this stuff too.
Thanks again.
MANJUNATH
MANJUNATH 2012년 11월 9일
i want to use 1 analog input; if i take more samples per trigger , the code will run still slow;
i need some improvement in my code to reduce time taken for start (ai)and getdata;
its not working when i write start in a loop and getdata outside the loop, either both codes will work inside the loop or outside ,
if it is inside the loop it is taking much time and outside the loop the code take the last sample
is there any methode to reduce this time thank u

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by