LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Stop Analog Read and Acquire Whatever Have Read? -LabVIEW

Hello NI Guys!

(sorry if I use same question, I am afraid that different "Select Location" leads to different answer area. So, here, I use "Select Location": LabVIEW)

 

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 Smiley Happy

0 Kudos
Message 1 of 4
(2,187 Views)

The answer is simple -- acquire 1000 points!  This will let you stop the loop after 1, 2, ...8, 9, or 10 seconds.  You can even "have your cake and Eat It, too" by having the ultimate output be an array of 1000, 2000, ..., 10000 points, depending on how you stopped.  Here's the idea (I'm simulating the DAQ with a Random Number Generator:

Stop after 1KStop after 1K

The Inner For Loop "simulates" a DAQ acquiring 1000 samples at 1kHz (on my laptop, this ran definitely slower, but that's Windows Clock for you ...).  It is surrounded by another For Loop to do the 10*1000 = 10,000 samples that you want -- notice that the tunnel leading out of the outer For Loop looks a little different (instead of a Box-in-a-Box, it has two small boxes side-by-side) -- it is a concatenating tunnel.  You can see the Tunnel options by right-clicking on the Tunnel (there are more ...).  Also, notice the little "Stop" sign in the For Loop's upper left corner -- this is a "Conditional Stop" that lets you "do what you want", terminate for For Loop early.

 

The above is a Snippet, but the code is easy enough and "educational" enough that you should try to create it yourself and see how it works.

 

Bob Schor

Message 2 of 4
(2,159 Views)

The NXG and LabVIEW tags reference the two types of LabVIEW currently available - it's important to choose the appropriate value so you can get the appropriate help. If your LabVIEW edition includes a year (e.g. LabVIEW 2018) then you want the non-NXG tag.

 

To create a For loop with a conditional stop, you need to right click on the For loop and find the item to tick about half way down 🙂


GCentral
0 Kudos
Message 3 of 4
(2,154 Views)

FYI, same question being discussed over here in one of the hardware groups.

 

-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 4 of 4
(2,146 Views)