Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Stop Analog Read and Acquire Whatever Have Read?

Hello NI Guys!

 

I am using NI USB 6002 and LabVIEW (I tried on .Net and ANCI C also).

I am doing Analog Input Continuous Data Acquisition, with rate 1000 Hz and Number of Samples of 10,000. --> So, the time to read needed is 10,000/1000 = 10 sec.

 

Sometimes, I want to just stop the data acquisition after 7 sec or less (not yet reach 10 sec or the 10,000 samples after I click Run or Start). 

But, after I click Stop button (in LabVIEW), the reading is still continuing until it gets 10,000 samples.

 

Is it possible to stop it immediately and I get whatever the Read have acquired? 

I mean if I stop after 7 sec from beginning, so I get about 7000 samples instead of 10,000 samples.

 

I have tried to set Timeout to less than 10 sec, but the error said "Some or all of the samples requested have not yet been acquired."

 

I open for all possible open answer.

Is there any method I can "interrupt" the Reading? Any other methods with same purpose are welcomed.

 

Thanks you 🙂

0 Kudos
Message 1 of 7
(2,292 Views)

It would help if you posted code.  You can't interrupt DAQmx Read *after* you call it, so the key is to write code such that you don't *need* to.

 

You could use a DAQmx Read property node to query for the # samples available, and then *decide* whether to call DAQmx Read yet based on that or other criteria.  Below is a simple starting point to illustrate:

 

 

-Kevin P

 

read available samples.png

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 7
(2,271 Views)

Thanks for the answer, Kevin 🙂

 

Actually, I used simple code on Example :Voltage - Continuous Input.

 

And I have tried Available Number of Sample in Read Property Node.

But, the value returned is always zero.

 

Same problem as https://forums.ni.com/t5/Multifunction-DAQ/DAQmxGetReadAvailSampPerChan-always-returns-zero/td-p/501...

 

My experiment also did show the same result. I did like the picture attached.

 

Image result for ni daqmx available samples per channel

0 Kudos
Message 3 of 7
(2,266 Views)

Please post your code, and it'll be especially helpful if you use "Save for Previous Version..." to save to an older format.  I for one would need 2016 or earlier.   That'll likely make it clear why you might get a 0 result when you query for # available samples.

 

I kinda skipped over the fact that you're doing *continuous* acquisition.  Normally that means that you'd be planning to iterate over the calls to DAQmx Read and accumulating the samples somewhere.  If so, it might be simplest just to read fewer samples per iteration.   That'll give you a faster loop rate, and you'll be more responsive to conditions that make you want to stop early.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 7
(2,257 Views)

Here is the program.

Saved for 2016 LabVIEW.

0 Kudos
Message 6 of 7
(2,254 Views)

What you posted looks like a direct copy of a shipping example.  (And it's broken for me in LV 2016 because of "Time Start" trigger type that I don't have available in my installation.)   It is *not* the code we were discussing that returns 0 when you query for the # samples available because it includes no such query.  It also shows no attempt to accumulate data nor to make a *decision* about whether to read and how many samples.

 

Spend a little time trying some things that were suggested.  If still stuck, come on back with your modified code.  Be sure to describe the problems clearly as well as what you'd *like* to have happen.  (Similar to your intro msg #1 which was nicely detailed.)

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 7 of 7
(2,250 Views)