how to use FIFO memory of DAQ

2 Ansichten (letzte 30 Tage)
MANJUNATH
MANJUNATH am 31 Okt. 2012
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 ?

Akzeptierte Antwort

Pedro Villena
Pedro Villena am 31 Okt. 2012
Bearbeitet: Pedro Villena am 9 Nov. 2012
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 Kommentare
MANJUNATH
MANJUNATH am 1 Nov. 2012
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 am 9 Nov. 2012
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by