how to use FIFO memory of DAQ

4 次查看(过去 30 天)
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