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;
chRate = 44100;
FIFO = 4095;
acqTime = FIFO/chRate/length(idChannels);
ai = analoginput('nidaq', 'Dev1');
addchannel(ai, idChannels);
set(ai,'SampleRate',chRate);
set(ai,'SamplesPerTrigger',FIFO);
num_iterations = 100;
data = zeros(num_iterations*FIFO);
for i = 1:num_iterations,
start(ai);
wait(ai, 2*acqTime);
data((i-1)*FIFO+1:i*FIFO) = getdata(ai);
end
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.