LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can i stop finite samples daqmx read in between ??

Solved!
Go to solution

Hi all,

        i want to read data for 10 secounds on receiving a trigger. for this im using daqmx task in finite sample mode and read the data on getting the trigger. it works very well but i cannot stop my vi in between when its reading the data. i have to wait for it to finish reading values and then stop the vi.

      so i switched to continuos sampling mode which allowed me to stop the vi whenever i want.

      i just want to know is there any way or property using which i can stop my finite read daqmx task whenever i want ????

 

0 Kudos
Message 1 of 6
(3,197 Views)

Depending on your architecture, but you could try using the DAQmx Stop Task whenever you are trying to abort the program.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(3,188 Views)
Solution
Accepted by topic author gargrahul

I'm guessing you're calling DAQmx Read with a special (-1) value for # samples.  That's also the default value if left unwired.  In a finite sampling task, it means to wait until the entire buffer has been filled with samples before returning.  Once you make such a call, you can't directly terminate it early.  You're stuck waiting for the buffer to fill or for the timeout to expire (10 second default value).

 

One way to avoid getting stuck is not to ask for samples that aren't already there.  You can query a DAQmx Read property known as "Available Samples" or something like that, and wire that result into a call to DAQmx Read.  That kind of call will return immediately with whatever data is presently available.  Subsequent calls will give you subsequent samples.

 

 

-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).
Message 3 of 6
(3,171 Views)

i agree with ur reply kevin.

once i make a call to DAQmx Read i had to wait for specified timeout or till the buffer fills. i want to avoid this situation and terminate the finite sampling task whenever i want.

"DAQmx Read property known as "Available Samples"" is one way of doing it. 

if there are more ways let me know so that i can choose the best one and kudos for correct answers Smiley Happy

0 Kudos
Message 4 of 6
(3,137 Views)
Solution
Accepted by topic author gargrahul

I have not tried this with finite samples, but it should work.

 

I typically use DAQmx Events with the Every N Samples Acquired into Buffer Event. I set up my event to acquire 100ms of data, the number of samples will be dependent on your sample rate. So this event fires every 100ms, if I want to terminate my capture I send a User Event to the same Event loop that starts a DAQ Stop and Abort sequence. This way your program is responsive. (The JKI State machine is useful for these methods.)

 

Cheers,

mcduff

 

 

Message 5 of 6
(3,127 Views)

I'd agree that structuring your code to use events (as suggested by mcduff) would be a cleaner approach.  Go ahead and give that a try, and post back with code if you run into issues.

 

 

-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 6 of 6
(3,114 Views)