Showing results for 
Search instead for 
Did you mean: 

DAQmx analog read returns zero values

I use DAQmx to read analog values from an SCXI board.  When my program starts, I use to start a predefined Task: 32 channels at 2 Hz continuous.  This is followed by a (multichannels multisamples waveform).  Since the program runs in a 1 second timed loop, I expect two samples per loop (actual program execution is 650 msec).
The first loop of execution, I get no readings, and the waveform dt=0; this causes errors in several subsequent Labview functions.  If I "continue" through those errors, the second loop I get a large number of samples and then (mostly) 2 samples per loop afterward.  I have found that I can eliminate this by the brute force method of putting the Start in a sequence box, followed by a frame with a 1 second delay, and then another frame with the initial read.
Since the DAQmx has the "count" value set to -1, I expected the program to wait for the first sample, return one set of values the first loop, and then two samples after that.
Additionally, sometimes (I can't find any causal relationship) one a given program loop the system returns no values; the returned waveforms are zeroes.  If I set the DAQmx Task to sample at 1 Hz and the program loop to be one second, I generally get alternating zero vales and two samples; it seems the timing between reading samples and the program loop varies.  In this case, with count=-1 I expected the program to wait for the sample, not return false values.
There are no error messages.
0 Kudos
Message 1 of 2

By setting the count to -1, you have told it to read all samples currently available in the buffer.  So in the first iteration the task hasn't had enough time to initialize the communication with the SCXI board and start storing data.  If you set the read count to 2, the read program should obtain 2 samples per loop.  I don't really know anything about timed loops but if you use a while loop and set the read count to 2, the vi will have to pause at the read function every iteration to wait for the 2 samples to be acquired and you should get pretty close to your 2hz rate.  At least, this is how I think it should work.

0 Kudos
Message 2 of 2