08-19-2019 09:15 AM
Hi all,
Solved! Go to Solution.
08-19-2019 10:10 AM
Some thoughts that might help you
08-19-2019 10:50 AM
Each loop you're reading 0.5s worth of data, but the timed loop holds you to 1s per iteration
I just wanted to add emphasis to this remark from cbutcher. The general topic of overconstrained loop timing when running DAQmx tasks has been a recurring theme I've been working to point out both fairly recently, and much longer ago (as well as several points in between).
It's a key concept to absorb, and once you do, you'll be a much better position to think about the relationship (and the distinction!) between your DAQ tasks and the timing needs of your *application*.
If you want to regulate the timing of a loop in your application, choose exactly 1 method for doing it. Let it be either timing regulated within the app ("Wait" function in a regular loop, possibly an official Timed Loop) OR timing determined by reading fixed packet sizes from a hw-timed DAQmx task. But not both at once. That's an overconstraint that almost always leads to problems.
-Kevin P
08-19-2019 11:27 AM
NI has some excellent tutorials on DAQmx available by searching on the Web. My favorite (which showed me how DAQmx is designed to work) has a title similar to "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications".
A key concept that Kevin mentioned is the following: suppose you set up a DAQmx Task to take 1000 samples at 1 kHz, and you set it to run continuously (this last point is important). Suppose you put it in a While Loop with nothing else in the Loop (except a Stop button). How fast will it run? Exactly once/second, right? Now, take another loop and put nothing inside it except a Wait (ms) function with 1000 wired to it (or, alternatively, a Timed Loop on a Windows platform). How fast will it run? Well, if your antivirus kicks in, or other things happen, it might not run once/second.
When in doubt, use the DAQ clocks, they are designed to be precise and accurate, and nothing interrupts them.
Bob Schor