09-20-2016 01:19 PM
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 ????
Solved! Go to Solution.
09-20-2016 01:29 PM
Depending on your architecture, but you could try using the DAQmx Stop Task whenever you are trying to abort the program.
09-20-2016 02:25 PM
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
09-21-2016 11:47 AM
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
09-21-2016 12:09 PM
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
09-21-2016 01:31 PM
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