Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I stop a DAQmx Read mid-acquisition?

Hello,

  I am taking long data sets- measurements that sometimes require the better part of an hour to complete- and which occasionally need to be aborted mid-acquisition.  Is this possible?

 

Currently I create, set the timing, and start the task with a DAQmx Read to collect 4 megasamples.  After all samples are acquired I stop and erase the task.  The VI that runs the DAQ is running in the background of a main VI (i.e. it was "called by reference").  If I abort the subvi it stops the main as well, which is unacceptable as it is controlling other functions of a delicate machine.  Any ideas?

 

Thank you,

  S. Wise

0 Kudos
Message 1 of 4
(3,194 Views)

Have you considered using the 'numbers of samples per channel' parameter to DAQmx Read to read in smaller increments (say, 100 samples at a time) in a loop, with a boolean control or some other signal to indicate that you should stop calling DAQmx Read further and abort the task?

——
Brandon Streiff
ni.com/compactdaq · ni.com/daq
0 Kudos
Message 2 of 4
(3,187 Views)

The problem with looped reading of smaller increments is that I fear I will lose data.  I am sampling a signal at close to the maximum rate this DAQ allows (2 signals at 300 kHz each), and the nature of the data (Fourier transform spectroscopy) is such that I can't afford to miss a single bit of it without rendering the rest useless.  I will experiment with this, however, to see at what sample rate I actually begin to lose datapoints.

 

Thanks,

  S. Wise

0 Kudos
Message 3 of 4
(3,162 Views)

If your sampling isn't able to keep up with the acquisition rate and you lose a sample, the DAQmx Read will return an error that you attempted to read samples that are no longer available, so you will be informed of whether you lost any data.  This is the same way that it would behave now if it wasn't able to transfer samples from the card's on-board buffer to PC memory.  DAQmx Read doesn't trigger a transfer from the card, just from the PC memory to your application.

 

I strongly recommend reading in smaller chunks and building the data into an array.  If you are not comfortable with that approach, you can set the Samples to Read on the DAQmx Read to your desired value, then pick a smaller timeout and handle the warnings that will be thrown until enough data is available.

Seth B.
Principal Test Engineer | National Instruments
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 4 of 4
(3,160 Views)