From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Fast reading and writing data via NI board

Hi, all!

I have a question about the PCI-6229 and how manualy from MATLAB to operate the input and output analog channels. I would talk about galvo-galvo scanning.

I need to set two coordinates for mirrors (2 output channels) and get one value from photomultiplier (one input channel).

1) If I try do this directly in cicle like this:

mydaq = daq.createSession('ni');
addAnalogOutputChannel(mydaq, 'dev2', 0:1, 'Voltage');
addAnalogInputChannel(mydaq, 'dev2', 'ai0', 'Voltage');

Xmin = -5;
Xmax = 5;
Ymin = -5;
Ymax = 5;

Xresolution = 128;
Yresolution = 128;

tt = 0;
tic
for iX = Xmin : (Xmax - Xmin)/(Xresolution-1) : Xmax
    for iY = Ymin : (Ymax - Ymin)/(Yresolution-1) : Ymax
        outputSingleScan(mydaq, [iX iY]);
        PMTvalue = mydaq.inputSingleScan;
    end
end
tt = toc

I see that run time is very large:

tt =
  180.0960

It is very slow as you see. (No any two frames per second). (And we want about 30 frames per second).

2) The faster way as I find is to use queueOutputData() like that:

mydaq = daq.createSession('ni');
addAnalogOutputChannel(mydaq, 'dev2', 0:1, 'Voltage');

rate = 300e3;
mydaq.Rate = rate;

f = 30;       
duration = 10;
t = (1:(duration*rate))/rate;

outputData(:,1) = 1.9*sin(8*pi*f*t + 0*pi/2)';
outputData(:,2) = 1.9*cos(7*pi*f*t)';
queueOutputData(mydaq, outputData);
startBackground(mydaq);

But in that case we cannot put in querry reading the input data.

The question is: what is the correct and fastest workaround here?

0 Kudos
Message 1 of 2
(3,062 Views)

You can create 2 sessions (I believe they are called tasks in labview), one for reading, one for writing, they can be independent.

 

0 Kudos
Message 2 of 2
(3,052 Views)