From Thursday, May 23rd (05:00 PM CDT) through Friday, April 24th (1:30 AM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
Screenshot from the help for number of samples per channel for a Read task :
Please add an option for a continuous sample task to read all currently available samples (-1) but with a wait for a minimum number of samples (#min). Behavior of this configuration :
#available samples >= #min : read all available samples
#available samples < #min : wait until #min samples are available or until timeout
This would be very useful in several cases. For example :
No extra coding to handle or avoid the error that appears if 0 sample is available.
Avoid the use of a wait function in the loop to ensure a minimum number of samples are available.
Functionality pretty similar to what you are describing is can be implemented pretty easily using the NI-DAQmx Read property "Available Samples per Channel"
Aside from the small increase in code, is there a reason this option won't work in your application?
Seth B. Principal Test Engineer | National Instruments Certified LabVIEW Architect Certified TestStand Architect
Here's the workaround I'd probably use. You don't have to use CPU polling for # available samples,
and you end up with all available data when buffer holds > min #.
-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).
Depending on the context of the application, you might also consider an event-driven approach:
However... now that I think about it, the event fires every time N samples are acquired into the buffer so it doesn't quite give you the behavior you desire of obtaining a minimum amount of samples if you are doing multiple iterations.