Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed--How to use DAQmx to acquire multi samples in a loop with delay?

Dear Sir or Madam,

I have a question about how to use DAQmx to acquire multi samples (1000 samples)
in a loop with certain delay time (1second). The sampling rate is 10,000 samples/second.
For the labview examples I found if the sampling rate is specified with DAQmx timing VI
the read vi is put in a loop without delay. I tried to put a delay I got an error when
I run it. There is some examples such as Cont Acq Resistance-SW Timed.vi with a delay
in a loop but the sampling rate is not specified. I know how to do it with the old DAQ vi
but have problems with DAQmx. What I want is to acquire certain samples (1000 samples)
with sampling rate (10,000 samples/sec) in a loop with delay time (1second). Any help is
high appreciated.

Thanks a lot!

Regards,

Tao
0 Kudos
Message 1 of 7
(3,597 Views)
Hello Tao,

"For the labview examples I found if the sampling rate is specified with DAQmx timing VI
the read vi is put in a loop without delay. I tried to put a delay I got an error when
I run it."
The reason there is not a delay in the loop is because the loop is forced to wait on the DAQmx Read.vi every iteration. For example, if you set a sampling rate of 10,000 Hz and set DAQmx Read to read 1000 samples, the loop will be forced to wait 100 ms per iteration (1000 samples / 10,000 samples/sec).

"What I want is to acquire certain samples (1000 samples) with sampling rate (10,000 samples/sec) in a loop with delay time (1second)."
For the reason listed above, this does not really make sense. If you set a rate of 10,000 Hz, it will acquire 1000 samples in .1 seconds. A loop delay of one second will lead to a buffer overflow error. To achieve a loop delay of 1 second, insert a wait function set to wait 1000 ms and wire a "-1" to the "number of samples per channel" terminal on the DAQmx Read.vi. This tells DAQmx to read all samples that are available in the buffer when the Read VI is called. At 10,000 Hz, you will read 10,000 samples every iteration.

I hope this helps. Let me know if you have any further questions.

Regards,
Sean C.
0 Kudos
Message 2 of 7
(3,579 Views)
Dear Sean,

Thanks for help. I want to make sure I understand what you said.

>The reason there is not a delay in the loop is because the loop is forced to wait on the DAQmx Read.vi every iteration. For >example, if you set a sampling rate of 10,000 Hz and set DAQmx Read to read 1000 samples, the loop will be forced to wait 100 ms >per iteration (1000 samples / 10,000 samples/sec).

Here the loop is forced to wait 100ms per iteration. I wonder is the wait here like wait for DAQ occurrence in the
traditional vi so other loops still have chance to run when the daq loop is waiting? or it just wait inside the loop and
won't return to the main program until the read vi complete its reading?


I still have question of the sample vi "Cont Acq Resistance Samples--SW timed. The number of samples to read is 10
for read vi, but what is the sampling rate for the 10 samples?

Thanks again for your help!

Regards,

Tao
0 Kudos
Message 3 of 7
(3,567 Views)
Hello Tao,

"I wonder is the wait here like wait for DAQ occurrence in the traditional vi so other loops still have chance to run when the daq loop is waiting? or it just wait inside the loop and won't return to the main program until the read vi complete its reading?"
Other loops can still run while the DAQmx Read.vi is waiting on the number of samples to become available. To verify this, simply place a separate while loop in your application and monitor the iteration terminal. You will see that it continues to iterate even when the DAQ loop is waiting.

"I still have question of the sample vi "Cont Acq Resistance Samples--SW timed. The number of samples to read is 10 for read vi, but what is the sampling rate for the 10 samples?"
The sampling rate of a software timed acquisition is set by the loop time. This VI has a default loop time of 250 ms which corresponds to a sampling rate of 4 Hz (1/0.250s).

I hope this helps. Please let me know if you have any further questions.

Regards,
Sean C.
0 Kudos
Message 4 of 7
(3,554 Views)
Dear Sean,

Thanks a lot for help! For the second question, I understand the loop time is determined
by the software delay. My question is that for each iteration, the number of samples per channel
is 10 for read vi. What is the sampling rate for these 10 samples?

Regards,

Tao
0 Kudos
Message 5 of 7
(3,549 Views)
Hello Tao,

I apologize, I misunderstood your question. When you create a finite acquisition task but don't set the sampling rate, the board will acquire the set amount of samples at it's maximum rate.

I hope this helps. Let me know if you have any further questions.

Regards,
Sean C.
0 Kudos
Message 6 of 7
(3,530 Views)
Hi Sean,

Thanks a lot for your help!

Regards,

Tao
0 Kudos
Message 7 of 7
(3,527 Views)