Showing results for 
Search instead for 
Did you mean: 

DAQmx Read Slow

Go to solution

@Kevin_Price wrote:

The trivial example is that the default value when unwired is -1.  This has the "magic number" meaning of "read all available samples (that haven't been read previously)."

Yes, I often forget this, then kick myself when it reads "all available samples" even if there are more I wanted it to read!  Which is why after one-trial testing, I say "Oops, forgot to wire Sample Size, dummy!"


A decent starting rule of thumb I follow is to read about 1/10 sec worth of samples at a time.  A sample rate of 1000 Hz means read 100 samples.  Bob's example followed that same guideline, 5 samples per read for 50 Hz sampling.

 Great minds think alike.


Bob Schor

Message 11 of 13

@coolhandLV7 wrote:

I'm not sure how to actually Read more samples and output the last value, as you mentioned in item (1), although i can picture how it should work.  If i set my DAQmx Read for N samples, i could read a chunk ->output the last value, then read another chunk repeat until the time is up...Hmmm  Not sure how to set that one up may have to play with that idea.

If reading an array of Waveforms, you use Index Array to get the waveform you want, then Get Waveform Components to get the Y value, and finally Delete From Array with the length and index left unwired.  The Delete From Array defaults to deleting the last element in the array, so you can get the single value from the "deleted portion".


@coolhandLV7 wrote:

Producer/Consumer loop was my next "thing to try", i'm specifically using TDMS streaming which from the literature is fast enough to not need it.  I'm not sure so i may try it.

File IO in general is slow.  TDMS will be slightly slower than streaming data to a binary file, but it comes with some good benefits.  But another option would be when you combine your tasks is to use the DAQmx Configure Logging function.  With that, you set up DAQmx to stream the data to a TDMS file.  You do not have to do anything else to log the data.  This is actually more efficient than using a Producer/Consumer since it avoids layers of software to get data to the disk.

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
Message 12 of 13

All thanks for the replies, i finally understand the timing setup for DAQmx, although it's counter intuitive to a newbie like me.  I have my loop firing at the desired speed.  I did reconfigure the code to include a producer consumer loop but found the timing was the key, either way it was slow until i configured the timing correctly.



You mentioned the DAQmx Configure, man i've played with this thing a little bit but can't get it to do what i want...maybe that's my next adventure.


Anyway thank you all.

0 Kudos
Message 13 of 13